Andy Gala
Andy Gala
  • 101
  • 482 397

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 78 (JAVASCRIPT) | SUBSETS I
zhlédnutí 7KPřed 3 lety
LEETCODE 78 (JAVASCRIPT) | SUBSETS 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 90 (JAVASCRIPT) | SUBSETS II
zhlédnutí 2,6KPřed 3 lety
LEETCODE 90 (JAVASCRIPT) | SUBSETS II
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

Komentáře

  • @izazk
    @izazk Před 8 dny

    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)); };

  • @Codingchess-rw7sp
    @Codingchess-rw7sp Před 8 dny

    Please continue the series sir more leetcode solution please

  • @viralpasad5222
    @viralpasad5222 Před 12 dny

    I wish the helper functions would've been explained more, you just built upon the fact that everyone has read the book.

  • @thiernodem5681
    @thiernodem5681 Před 17 dny

    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!

  • @Taiwaneze
    @Taiwaneze Před měsícem

    thats was soo poorly explained

  • @rehamgamal1722
    @rehamgamal1722 Před měsícem

    the audio is so low I can't hear you. but great job!

  • @itsokaytobesergey
    @itsokaytobesergey Před 2 měsíci

    left + (right - left) === right

  • @muhammednehyan5443
    @muhammednehyan5443 Před 2 měsíci

    great explanation

  • @rrl9786
    @rrl9786 Před 2 měsíci

    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.

  • @TheKylesampson
    @TheKylesampson Před 2 měsíci

    Best vid I found today for understanding quick sort. Thank you!

  • @sportsmanship2024
    @sportsmanship2024 Před 2 měsíci

    I hardly heard your voice, I don't know if it is from your microphone or you are not speaking louder...

  • @SouravCheck
    @SouravCheck Před 3 měsíci

    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; } };

    • @SouravCheck
      @SouravCheck Před 3 měsíci

      why it is not running.....................

  • @Ly-fj3dq
    @Ly-fj3dq Před 3 měsíci

    thank you so much for this video!!!! helps me a lot

  • @Big_13ang
    @Big_13ang Před 3 měsíci

    👌👌

  • @peterlazkweb9111
    @peterlazkweb9111 Před 4 měsíci

    Nice video 🤗, just that the sound wasn't clear enough

  • @maxwong4657
    @maxwong4657 Před 4 měsíci

    Thank you so much. This solution is the most understandable!

  • @josygeorge5671
    @josygeorge5671 Před 4 měsíci

    the 3rd example doesn't work, but needs an absolute value comparison in the diff calculation(values with less than zero)

  • @HasmeRafsanjani
    @HasmeRafsanjani Před 4 měsíci

    Nice Explanation but your video sound is too low .

  • @nandakumart2331
    @nandakumart2331 Před 4 měsíci

    thank you

  • @pranavbhat92
    @pranavbhat92 Před 4 měsíci

    Thank you. Your explanation felt intuitive!

  • @stevemiller123
    @stevemiller123 Před 5 měsíci

    It seems there's no need to include 0 in your reducer. The method will still properly add up all your vaules.

  • @joshluca763
    @joshluca763 Před 5 měsíci

    Very solid explanation. Much appreciated!

  • @jamesbond86
    @jamesbond86 Před 5 měsíci

    Great Job! Love your content

  • @enriquegrageda
    @enriquegrageda Před 5 měsíci

    Had to watch it 3 times, it makes sense, thanks for making this video!

  • @jillysong4751
    @jillysong4751 Před 6 měsíci

    What if all values in first array are greater than those in second array and the first pointer goes out of range first?

  • @ethaneth6481
    @ethaneth6481 Před 6 měsíci

    Your explaination is very incomplete, you totally skip explaining the update part.

  • @michaelesparza7917
    @michaelesparza7917 Před 6 měsíci

    you lost me on this one bro

  • @chandansingh-sb3il
    @chandansingh-sb3il Před 6 měsíci

    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

  • @OnkarJoshi422
    @OnkarJoshi422 Před 6 měsíci

    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.

  • @user-pm2kx1vi1e
    @user-pm2kx1vi1e Před 6 měsíci

    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; };

  • @michaelesparza7917
    @michaelesparza7917 Před 6 měsíci

    ummmmmm but the last one doesn't make a region it just makes a 3rd branch from node one. IM so confused

  • @user-pm2kx1vi1e
    @user-pm2kx1vi1e Před 7 měsíci

    /** * 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; };;

  • @akinhwan
    @akinhwan Před 7 měsíci

    these videos are a life saver thanks andy

  • @hassaniyouness8024
    @hassaniyouness8024 Před 7 měsíci

    the content is great hope you get back soon

  • @akash693
    @akash693 Před 7 měsíci

    Well explained!

  • @Ivan_Dev
    @Ivan_Dev Před 8 měsíci

    Can anyone tell me which 'drawing' software is he using plz?

  • @arromero491
    @arromero491 Před 8 měsíci

    Thanks a lot, I understand everthing!

  • @codingispower1816
    @codingispower1816 Před 8 měsíci

    This problem is so confusing even with this great explanation. i,j i-1, j-1 haha I need to slowly repeat this vid

  • @zscoder
    @zscoder Před 8 měsíci

    Where do we start with your DSA videos?

  • @user-xn3ff2sf7q
    @user-xn3ff2sf7q Před 8 měsíci

    Thanks for your insight and good content.

  • @nicknderitu6013
    @nicknderitu6013 Před 9 měsíci

    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; };

  • @UmaSahni.
    @UmaSahni. Před 9 měsíci

    blessed with your explanation !!

  • @natebland4066
    @natebland4066 Před 9 měsíci

    I appreciate that you kept the debuggining process in. Makes me feel better about making mistakes :)

  • @TeeJay327-yg8gm
    @TeeJay327-yg8gm Před 9 měsíci

    Simply brilliant! Extremely intuitive and easy to remember - thanks so much for this and many of your other videos, Andy!

  • @Digitalkmusicproduction
    @Digitalkmusicproduction Před 9 měsíci

    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

  • @darshanakv4946
    @darshanakv4946 Před 9 měsíci

    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?

    • @mukulgaddhyan3954
      @mukulgaddhyan3954 Před 4 měsíci

      It is exceeding the suggested time limit in leetcode, hence it won't run for a few large input data.

    • @mukulgaddhyan3954
      @mukulgaddhyan3954 Před 4 měsíci

      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]; } }

  • @sianwa11
    @sianwa11 Před 9 měsíci

    Thanks for the explanation. I initially started using a linked list stack and it got way too complicated. This solution is great👍🏾

  • @TheHipHopVlog
    @TheHipHopVlog Před 9 měsíci

    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; }

  • @dfelips
    @dfelips Před 9 měsíci

    voice is so low

  • @zacharyhorton8046
    @zacharyhorton8046 Před 9 měsíci

    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.