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-rw7sp18 күн бұрын
Please continue the series sir more leetcode solution please
@viralpasad522222 күн бұрын
I wish the helper functions would've been explained more, you just built upon the fact that everyone has read the book.
@thiernodem568127 күн бұрын
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Ай бұрын
thats was soo poorly explained
@rehamgamal1722Ай бұрын
the audio is so low I can't hear you. but great job!
@itsokaytobesergey2 ай бұрын
left + (right - left) === right
@muhammednehyan54433 ай бұрын
great explanation
@rrl97863 ай бұрын
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.
@TheKylesampson3 ай бұрын
Best vid I found today for understanding quick sort. Thank you!
@sportsmanship20243 ай бұрын
I hardly heard your voice, I don't know if it is from your microphone or you are not speaking louder...
thank you so much for this video!!!! helps me a lot
@Big_13ang4 ай бұрын
👌👌
@peterlazkweb91114 ай бұрын
Nice video 🤗, just that the sound wasn't clear enough
@maxwong46574 ай бұрын
Thank you so much. This solution is the most understandable!
@josygeorge56714 ай бұрын
the 3rd example doesn't work, but needs an absolute value comparison in the diff calculation(values with less than zero)
@HasmeRafsanjani5 ай бұрын
Nice Explanation but your video sound is too low .
@nandakumart23315 ай бұрын
thank you
@pranavbhat925 ай бұрын
Thank you. Your explanation felt intuitive!
@stevemiller1235 ай бұрын
It seems there's no need to include 0 in your reducer. The method will still properly add up all your vaules.
@joshluca7635 ай бұрын
Very solid explanation. Much appreciated!
@jamesbond865 ай бұрын
Great Job! Love your content
@enriquegrageda6 ай бұрын
Had to watch it 3 times, it makes sense, thanks for making this video!
@jillysong47516 ай бұрын
What if all values in first array are greater than those in second array and the first pointer goes out of range first?
@ethaneth64816 ай бұрын
Your explaination is very incomplete, you totally skip explaining the update part.
@michaelesparza79176 ай бұрын
you lost me on this one bro
@chandansingh-sb3il6 ай бұрын
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
@OnkarJoshi4226 ай бұрын
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-pm2kx1vi1e7 ай бұрын
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; };
@michaelesparza79177 ай бұрын
ummmmmm but the last one doesn't make a region it just makes a 3rd branch from node one. IM so confused
Can anyone tell me which 'drawing' software is he using plz?
@arromero4918 ай бұрын
Thanks a lot, I understand everthing!
@codingispower18169 ай бұрын
This problem is so confusing even with this great explanation. i,j i-1, j-1 haha I need to slowly repeat this vid
@zscoder9 ай бұрын
Where do we start with your DSA videos?
@user-xn3ff2sf7q9 ай бұрын
Thanks for your insight and good content.
@nicknderitu60139 ай бұрын
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.9 ай бұрын
blessed with your explanation !!
@natebland40669 ай бұрын
I appreciate that you kept the debuggining process in. Makes me feel better about making mistakes :)
@TeeJay327-yg8gm9 ай бұрын
Simply brilliant! Extremely intuitive and easy to remember - thanks so much for this and many of your other videos, Andy!
@Digitalkmusicproduction9 ай бұрын
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
@darshanakv49469 ай бұрын
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?
@mukulgaddhyan39545 ай бұрын
It is exceeding the suggested time limit in leetcode, hence it won't run for a few large input data.
@mukulgaddhyan39545 ай бұрын
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]; } }
@sianwa1110 ай бұрын
Thanks for the explanation. I initially started using a linked list stack and it got way too complicated. This solution is great👍🏾