![Andy Gala](/img/default-banner.jpg)
- 101
- 482 397
Andy Gala
United States
Registrace 13. 03. 2014
Leetcode video solutions in Javascript
How to scale a Backend Microservice to 10K RPS
In-depth tech talk on how to scale a Backend Microservice with Andy Gala.
zhlédnutí: 3 601
Video
LEETCODE 199 (JAVASCRIPT) | BINARY TREE RIGHT SIDE VIEW
zhlédnutí 2,7KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 199.
LEETCODE 285 (JAVASCRIPT) | INORDER SUCCESSOR IN BST
zhlédnutí 1,3KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 285.
LEETCODE 236 (JAVASCRIPT) | LOWEST COMMON ANCESTOR OF A BINARY TREE
zhlédnutí 3,6KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 236.
LEETCODE 113 (JAVASCRIPT) | PATH SUM II
zhlédnutí 2,5KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 113.
LEETCODE 112 (JAVASCRIPT) | PATH SUM
zhlédnutí 3KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 112.
LEETCODE 429 (JAVASCRIPT) | N-ARY TREE LEVEL ORDER TRAVERSAL
zhlédnutí 2,2KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 429.
LEETCODE 701 (JAVASCRIPT) | INSERT INTO A BINARY SEARCH TREE
zhlédnutí 1,4KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 701.
LEETCODE 543 (JAVASCRIPT) | DIAMETER OF BINARY TREE
zhlédnutí 3,4KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 543.
LEETCODE 108 (JAVASCRIPT) | CONVERT SORTED ARRAY TO BINARY SEARCH TREE
zhlédnutí 4,3KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 108.
LEETCODE 250 (JAVASCRIPT) | COUNT UNIVALUE SUBTREES
zhlédnutí 2KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 250.
LEETCODE 105 (JAVASCRIPT) | CONSTRUCT BINARY TREE FROM PREORDER AND INORDER TRAVERSAL
zhlédnutí 3KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 105.
LEETCODE 103 (JAVASCRIPT) | BINARY TREE ZIGZAG LEVEL ORDER TRAVERSAL
zhlédnutí 1,9KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 103.
LEETCODE 107 (JAVASCRIPT) | BINARY TREE LEVEL ORDER TRAVERSAL II
zhlédnutí 1,4KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 107.
LEETCODE 144 (JAVASCRIPT) | BINARY TREE PREORDER TRAVERSAL
zhlédnutí 4,5KPřed 3 lety
Hey everyone. Check out this in-depth solution for leetcode 144.
LEETCODE 102 (JAVASCRIPT) | BINARY TREE LEVEL ORDER TRAVERSAL
zhlédnutí 6KPřed 3 lety
LEETCODE 102 (JAVASCRIPT) | BINARY TREE LEVEL ORDER TRAVERSAL
LEETCODE 784 (JAVASCRIPT) | LETTER CASE PERMUTATION
zhlédnutí 7KPřed 3 lety
LEETCODE 784 (JAVASCRIPT) | LETTER CASE PERMUTATION
LEETCODE 17 (JAVASCRIPT) | LETTER COMBINATIONS OF A PHONE NUMBER
zhlédnutí 4,9KPřed 3 lety
LEETCODE 17 (JAVASCRIPT) | LETTER COMBINATIONS OF A PHONE NUMBER
LEETCODE 51 & 52 (JAVASCRIPT) | N QUEENS I & II
zhlédnutí 2,9KPřed 3 lety
LEETCODE 51 & 52 (JAVASCRIPT) | N QUEENS I & II
LEETCODE 47 (JAVASCRIPT) | PERMUTATIONS II
zhlédnutí 2,9KPřed 3 lety
LEETCODE 47 (JAVASCRIPT) | PERMUTATIONS II
LEETCODE 131 (JAVASCRIPT) | PALINDROME PARTITIONING I
zhlédnutí 2KPřed 3 lety
LEETCODE 131 (JAVASCRIPT) | PALINDROME PARTITIONING I
LEETCODE 46 (JAVASCRIPT) | PERMUTATIONS I
zhlédnutí 13KPřed 3 lety
LEETCODE 46 (JAVASCRIPT) | PERMUTATIONS I
LEETCODE 494 (JAVASCRIPT) | TARGET SUM
zhlédnutí 1,8KPřed 3 lety
LEETCODE 494 (JAVASCRIPT) | TARGET SUM
LEETCODE 22 (JAVASCRIPT) | GENERATE PARENTHESES
zhlédnutí 4,4KPřed 3 lety
LEETCODE 22 (JAVASCRIPT) | GENERATE PARENTHESES
LEETCODE 40 (JAVASCRIPT) | COMBINATION SUM II
zhlédnutí 2,9KPřed 3 lety
LEETCODE 40 (JAVASCRIPT) | COMBINATION SUM II
LEETCODE 216 (JAVASCRIPT) | COMBINATION SUM III
zhlédnutí 2,7KPřed 3 lety
LEETCODE 216 (JAVASCRIPT) | COMBINATION SUM III
LEETCODE 39 (JAVASCRIPT) | COMBINATION SUM I
zhlédnutí 4,6KPřed 3 lety
LEETCODE 39 (JAVASCRIPT) | COMBINATION SUM I
LEETCODE 509 (JAVASCRIPT) | FIBONACCI NUMBER
zhlédnutí 2,1KPřed 3 lety
LEETCODE 509 (JAVASCRIPT) | FIBONACCI NUMBER
Simple solution: /** * @param {number[]} nums * @param {number} k * @return {void} Do not return anything, modify nums in-place instead. */ var rotate = function (nums, k) { k = k % nums.length; nums = nums.slice(-k).concat(nums.slice(0, -k)); };
Please continue the series sir more leetcode solution please
I wish the helper functions would've been explained more, you just built upon the fact that everyone has read the book.
I understands codes more when it's been coded than explained on paper or board. You explained it very well, and it's actually easy to comprehend. Thank you!
thats was soo poorly explained
the audio is so low I can't hear you. but great job!
left + (right - left) === right
great explanation
Man, thank you so much. I am beginning to get pretty comfortable with linked lists, but this problem turned my brain into mush and I finally decided it was better to just see it demonstrated and then use that knowledge in future problems. Your explanation was so clear and concise, I finally actually understand this fully.
Best vid I found today for understanding quick sort. Thank you!
I hardly heard your voice, I don't know if it is from your microphone or you are not speaking louder...
hello, /** * @param {string} s * @return {boolean} */ var isValid = function(s) { let input=s.split(""); let count=0; for(let i=0;i<input.length;i++) { for(let j=i+1;j<input.length;j++) { if(input[i]=='('&& input[j]==')' || input[i]=='[' && input[j]==']' || input[i]=='{'&& input[j]=='}') { count++; } if( input[i]=='(' && input[j+1]==')' || input[i]=='{' && input[j+1]=='}' ||input[i]=='[' && input[j+1]==']') { return false; } } } if((count*2)==input.length) { return true; } else { return false; } };
why it is not running.....................
thank you so much for this video!!!! helps me a lot
👌👌
Nice video 🤗, just that the sound wasn't clear enough
Thank you so much. This solution is the most understandable!
the 3rd example doesn't work, but needs an absolute value comparison in the diff calculation(values with less than zero)
Nice Explanation but your video sound is too low .
thank you
Thank you. Your explanation felt intuitive!
It seems there's no need to include 0 in your reducer. The method will still properly add up all your vaules.
Very solid explanation. Much appreciated!
Great Job! Love your content
Had to watch it 3 times, it makes sense, thanks for making this video!
What if all values in first array are greater than those in second array and the first pointer goes out of range first?
Your explaination is very incomplete, you totally skip explaining the update part.
you lost me on this one bro
for (let r = 0; r < matrix.length; r++) { for (let c = r; c < matrix[0].length; c++) { [matrix[c][r],matrix[r][c]] = [matrix[r][c],matrix[c][r]] } } Why this is generating error in leetcode IDE but runs in jsfiddle
Time complexity for this one is O(n*2) because Array.prototype.reverse has O(n) and next two reversals have k and n - k combined O(n) and all combined O(n*2). To make it O(n), we can use the same revNums function for whole array reverse as well.
var levelOrder = function(root) { if(!root) return []; let queue = [root]; let result = []; while(queue.length){ let len = queue.length; result.push(queue.map(node => node.val)); while(len--){ let node = queue.shift();// for(let child of node.children){ queue.push(child) } } } return result; };
ummmmmm but the last one doesn't make a region it just makes a 3rd branch from node one. IM so confused
/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } */ /** * @param {TreeNode} root * @param {number} targetSum * @return {number[][]} */ var pathSum = function(root, targetSum) { if(!root) return []; const paths=[]; const dfs = (node, sum, slate) => { if(node.left === null && node.right === null){ if(sum === node.val){ slate.push(node.val); paths.push(slate.slice()); slate.pop(); } } if(node.left){ slate.push(node.val); dfs(node.left, sum - node.val, slate); slate.pop(); } if(node.right){ slate.push(node.val); dfs(node.left, sum - node.val, slate); slate.pop(); } } dfs(root, targetSum, []); return paths; };;
these videos are a life saver thanks andy
the content is great hope you get back soon
Well explained!
Can anyone tell me which 'drawing' software is he using plz?
Thanks a lot, I understand everthing!
This problem is so confusing even with this great explanation. i,j i-1, j-1 haha I need to slowly repeat this vid
Where do we start with your DSA videos?
Thanks for your insight and good content.
You could also use a map for parens which I feel is more intuitive. Here's a solution I found easier to understand. /** * @param {string} s * @return {boolean} */ var isValid = function (s) { //handle the edge case //create a map holding the opening brackets macthed to the closing bracket //create a stack to hold the opening bracket //loop through s and check if the bracket in the stack matches the current bracket //if not push item to the stack //if stack is empty return true else false if (s.length % 2 != 0) return false; const map = { "(": ")", "[": "]", "{": "}" } const stack = []; stack.push(s[0]); for (let i = 1; i < s.length; i++) { let stackEl = stack[stack.length - 1]; if (map[stackEl] == s[i]) { stack.pop(); } else { stack.push(s[i]); } } return stack.length == 0; };
blessed with your explanation !!
I appreciate that you kept the debuggining process in. Makes me feel better about making mistakes :)
Simply brilliant! Extremely intuitive and easy to remember - thanks so much for this and many of your other videos, Andy!
I think line 19 the else statement could be removed, because if the value is more than one the while loop wouldn't run, so it would never see it. Right? or am I missing something? great video btw
I have been trying a code using 2 for loops but somehow the output is not coming in the code editor of leet code but in the chrome console,it is coming as expected. Any help?
It is exceeding the suggested time limit in leetcode, hence it won't run for a few large input data.
I am assuming your code looks something like this:- for(let i=1; i<=k; i++){ for(let j=0; j<nums.length; j++){ let temp = nums[j]; nums[j] = nums[0]; nums[0] = temp; if(j==nums.length) nums[0]=nums[j]; } }
Thanks for the explanation. I initially started using a linked list stack and it got way too complicated. This solution is great👍🏾
Just wanted to share my solution with the community: const lengthOfLongestSubstring = (s) => { let seen = new Set () let max = 0 let left = 0 let right = 0 while(right < s.length){ if(!seen.has(s[right])){ seen.add(s[right]) max = Math.max(max, right - left + 1) right ++ } else { seen.delete(s[left]) left++ } } return max; }
voice is so low
function lengthOfLongestSubstring(s) { if (!s.length) return '' let max = -Infinity let set = new Set() // how do we shrink the run when we find a duplicate? let a = 0 for (let z = 0; z < s.length; z++) { if (set.has(s[z])) while (set.has(s[z])) set.delete(s[a++]) set.add(s[z]) max = Math.max(max, z - a + 1) } return max } The time complexity of the lengthOfLongestSubstring() function is O(n), where n is the length of the string s. This is because the function iterates over the string at most once, and each iteration performs a constant number of operations. The space complexity of the function is also O(n), because the function uses a set to store the unique characters in the current substring. In the worst case, all of the characters in the string will be unique, and the set will contain n elements. How does the function shrink the run when it finds a duplicate? The function shrinks the run by moving the left pointer (a) forward until it reaches the first character that is not in the set. This ensures that the substring always contains unique characters. For example, consider the string s = "abcabcbb". When the function reaches the character c at index 2, it will add it to the set and update the maximum length of the substring to 3. However, when the function reaches the next c at index 3, it will find that it is already in the set. Therefore, the function will move the left pointer forward to index 1, which is the first character that is not in the set. The function will then continue iterating over the string, starting at index 1. In the end, the function will return the maximum length of the substring, which is 3.