This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.geeksforgeeks.org/print-binary-tree-vertical-order/ | |
class Node { | |
constructor(val, left, right) { | |
this.val = val; | |
this.left = left; | |
this.right = right; | |
} | |
} | |
function verticalOrder(root, arr) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.geeksforgeeks.org/serialize-deserialize-binary-tree/ | |
class Node { | |
constructor(val, left, right) { | |
this.val = val; | |
this.left = left; | |
this.right = right; | |
} | |
} | |
function inorder(root, arr) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/ | |
class Node { | |
constructor(val, left, right) { | |
this.val = val; | |
this.left = left; | |
this.right = right; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.geeksforgeeks.org/convert-a-given-binary-tree-to-doubly-linked-list-set-4/ | |
class Node { | |
constructor(val, left, right) { | |
this.val = val; | |
this.left = left; | |
this.right = right; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://codeburst.io/implementing-a-complete-binary-heap-in-javascript-the-priority-queue-7d85bd256ecf | |
// Linked list | |
class Node { | |
constructor(val, priority) { | |
this.val = val; | |
this.priority = priority; | |
this.next = null; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildTree(arr, root, idx, n) { | |
const leftIdx = 2 * idx + 1; | |
const rightIdx = 2 * idx + 2; | |
if (idx < n) { | |
root = { | |
val: arr[idx], | |
left: buildTree(arr, root ? root.left : null, leftIdx, n), | |
right: buildTree(arr, root ? root.right : null, rightIdx, n), | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serialize(root) { | |
if (!root) { | |
return 'X,' | |
} | |
const left = serialize(root.left); | |
const right = serialize(root.right); | |
return root.val += `,${left}${right}`; | |
} | |
function deserialize(str) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"FunctionName": "transcode-video", | |
"FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:transcode-video", | |
"Runtime": "nodejs10.x", | |
"Role": "arn:aws:iam::000000000000:role/lambda-s3-execution-role", | |
"Handler": "index.handler", | |
"CodeSize": 5665493, | |
"Description": "", | |
"Timeout": 3, | |
"MemorySize": 128, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// package.json | |
{ | |
... | |
"scripts": { | |
... | |
"deploy": "aws lambda update-function-code --function-name arn:aws:lambda:us-east-1:000000000000:function:transcode-video --zip-file fileb://Lambda-Deployment.zip", | |
"predeploy": "rm Lambda-Deployment.zip > /dev/null && npm prune --production && zip -r Lambda-Deployment.zip * -x *.zip *.log", | |
"postdeploy": "npm i --offline" | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"FunctionName": "transcode-video", | |
"FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:transcode-video", | |
"Runtime": "nodejs10.x", | |
"Role": "arn:aws:iam::000000000000:role/lambda-s3-execution-role", | |
"Handler": "index.handler", | |
"CodeSize": 26312199, | |
"Description": "", | |
"Timeout": 3, | |
"MemorySize": 128, |