The LeetCode Fallacy
6:08
2 ай бұрын
I quit Amazon after two months
10:09
My Last Day at Google
4:59
Жыл бұрын
GPT-4 is OVERHYPED
3:51
Жыл бұрын
Technologies I'm Learning in 2023
9:37
Will AI replace programmers?
4:08
Is FAANG dead?
6:28
Жыл бұрын
Tech Layoffs & Hiring Freezes
5:57
Пікірлер
@spageen
@spageen 9 сағат бұрын
3:10 <- pee pee button
@pumpkinpie798
@pumpkinpie798 10 сағат бұрын
and what to do if its asking for a maximal rectangle of 0's .. I don't understand
@aakashavril
@aakashavril 11 сағат бұрын
I like the solutions by neetcode but this one is particularly very confusing and does not come naturally. The following approach builds each permutation choosing one element at a time and further building up the solution. class Solution: def permute(self, nums: List[int]) -> List[List[int]]: res = [] self.dfsPermute(res,nums,[]) return res def dfsPermute(self,res,nums,curr): if len(curr)==len(nums): # base case when we found one permutation solution res.append(curr.copy()) # go over each element add it to the list for n in nums: # check to avoid dulicate value in the arr if n in curr: continue else: # call recursively for each case curr.append(n) self.dfsPermute(res,nums,curr) #undo the last chosen element and go to the other decision branch tree curr.pop()
@mso4324
@mso4324 11 сағат бұрын
I was struggling with understanding solutions in the forum, this really helped clarify how recurrence relation is working here
@shadowsw8020
@shadowsw8020 12 сағат бұрын
This is kinda crazy
@bhuvankiransagarg.b9678
@bhuvankiransagarg.b9678 12 сағат бұрын
void rotate(int *nums, int numsSize, int k) { int t=0; while(t<k){ for(int i=numsSize-1;i>=0;i--){ *(nums + (i+1))=*(nums+i); } numsSize++; *nums=*(nums + numsSize-1); numsSize--; t++; } } This code works fine on compilers but does not work on Leetcode can somebody explain plz 🥲😭🙏
@eltongbollie1881
@eltongbollie1881 12 сағат бұрын
return len(nums) != len(set(nums))
@stylisgames
@stylisgames 13 сағат бұрын
I actually got this one without looking at any hints! 🙌Doing all of the previous BST problems beforehand helped greatly.
@maitreyakanitkar8742
@maitreyakanitkar8742 13 сағат бұрын
noice
@KartikeyTT
@KartikeyTT 13 сағат бұрын
Guys just use the same code as that of subset 2 and just add extra base condtions where you exceed the sum and where you find the sum
@KartikeyTT
@KartikeyTT 13 сағат бұрын
the code doesnt match the explanation. In the explanation you were making 2 decisions....but in the code the number of decisions is decided b the loop
@youreyesarebleeding1368
@youreyesarebleeding1368 13 сағат бұрын
Man, i was SO close to getting the solution on this one, i spent maybe an hour on it. After I do all of the backtracking problems i'll return to this one and try to solve it on my own again, I was thinking about this one for hours. great video, thanks for all of the resources you've put out there!
@aurkom
@aurkom 13 сағат бұрын
``` def plusOne(self, digits: List[int]) -> List[int]: idx = len(digits)-1 while idx >= 0: if digits[idx] != 9: digits[idx] += 1 return digits else: digits[idx] = 0 idx -= 1 return [1] + digits ```
@mentalyunstable2872
@mentalyunstable2872 14 сағат бұрын
Why not convert whole string to lowercase alphanumerics, then just compare s == s[::-1]?
@mentalyunstable2872
@mentalyunstable2872 14 сағат бұрын
Speed reasons?
@sidt1572
@sidt1572 13 сағат бұрын
Might be both since you'll have to create a new string and converting them all to it into lower case would also take time. That is another O(n) on top of the O(n) in the main loop. Hence his solution just check if those two specific spot are equal to each other in their lower case version or ignore anything non-alphabet-numberic. Since we are just checking if the Phrase is a Plindrome, we do not want to modify the given Phrase either. This method would only have to iterate the whole phrase once and it would not need anymore new spaces other than L and R. Making it O(n). I am still learning as well but that is my take.
@alansun697
@alansun697 13 сағат бұрын
I think even if we can modify the original string, removing the non alphanumerics characters is slow because is removal is O(n) time.
@apriil9822
@apriil9822 14 сағат бұрын
There's no way for me to think of this solution. Good explanation, thanks!
@Sulerhy
@Sulerhy 15 сағат бұрын
So confusing. Anyways thank you for your explain, it helps me step by step
@jacobophoven90
@jacobophoven90 15 сағат бұрын
would be faster to just convert thw whole string to lower
@shipweck6253
@shipweck6253 15 сағат бұрын
not necessarily. Making the entire string lowercase at once would take more time if the string was found to not be a palindrome within the first few characters, so we would be copying the entire string to lowercase when we only needed the first few characters.
@NeetCode
@NeetCode 15 сағат бұрын
that works but would require O(n) extra space
@AmiraKhaled-ul6li
@AmiraKhaled-ul6li 15 сағат бұрын
Is this course enough to jump into data structure and algorithms or do I need to dive more into python?
@NeetCode
@NeetCode 14 сағат бұрын
Yeah it teaches you the core syntax and features of Python. Will be launching a Python for coding interviews course next week which shows you how to use all of the built in algorithms and data structures.
@AmiraKhaled-ul6li
@AmiraKhaled-ul6li 14 сағат бұрын
@@NeetCode Thx. I'm looking forward to it🔥🔥
@SOMESHKHANDELIA
@SOMESHKHANDELIA 16 сағат бұрын
I tried this approach whereby I moved the pointers such as to maximise the area at each step, but I got wrong answer. I don't understand why Neetcode's solution is mathematically guaranteed to work. The problem looks to be a greedy one, but maximising the area locally gave me wrong answer. Why does NeetCode's solution work? My solution for reference: class Solution { public: int getArea(int left_idx, int left_val, int right_idx, int right_val){ return min(left_val, right_val) * (right_idx - left_idx); } int maxArea(vector<int>& height) { int left_idx = 0; int right_idx = height.size()-1; int max_area = -1; while(left_idx <= right_idx){ int curr_area = getArea(left_idx, height[left_idx], right_idx, height[right_idx]); if(curr_area>max_area){ max_area = curr_area; } if (left_idx == right_idx){ break; } // let us try to decide which pointer to move int left_move_area = getArea(left_idx+1, height[left_idx+1], right_idx, height[right_idx]); int right_move_area = getArea(left_idx, height[left_idx], right_idx-1, height[right_idx-1]); if(left_move_area >= right_move_area){ left_idx++; } else{ right_idx--; } } return max_area; } }; EDIT: I saw a reply by @hunterlee1249. It makes sense now.
@someshshridhar9998
@someshshridhar9998 17 сағат бұрын
@Neetcode Hey I guys , i was fired from prev company due to recession , its been six months without any job!! I dont know what i am doing wrong or where i am going wrong, its hard to live like this I think sometimes like this is not the way i intended to live i had some big dreams which are impossible now. I just wanted to let these things out. I was curious @Neetcode how many months gap did you had after quitting from amazon ?
@saisurisetti6278
@saisurisetti6278 17 сағат бұрын
How behind are you? Me: "Aight lets do this. Brute Force first.. wait how do we brute force?"
@user-kn4wt
@user-kn4wt 18 сағат бұрын
this is not leetcode. thumgs down
@silverpixel2
@silverpixel2 18 сағат бұрын
you're amazing, thank you so much!
@rkpscars3923
@rkpscars3923 18 сағат бұрын
How to reach your level 🥺
@user-ul9rs2ge7x
@user-ul9rs2ge7x 19 сағат бұрын
A moment of silence for those who got this question in an interview (bonus points for it being the first)
@vivek2319
@vivek2319 19 сағат бұрын
Bruh taking his KZfaq Channel on a different level 📈 🔥💯
@KartikeyTT
@KartikeyTT 19 сағат бұрын
ty bro
@KarthikChintalaOfficial
@KarthikChintalaOfficial Күн бұрын
Like the approach. But it's tedious to really remember and do it. I like the transposing and reversing using a 2 ptr approach to do this.
@user-hf7ef6nm4s
@user-hf7ef6nm4s Күн бұрын
nlogn or knlogn where k is the avg. length of the strings were comparing?
@atg878
@atg878 Күн бұрын
great of the greatest 🙌🙌
@Techgether
@Techgether Күн бұрын
1. Why isnt the time complexity O(p -(p-q)) since each of the function call will involve p and q together? - In the event where p has deeper depth than q - it will be O(p -(p-q)) since we will stop when reached the end of q - And in the event where p has lesser depth then q - it will be O(p) since we reached the end of p and returned. Thus, taking the worst case so should be O(p -(p-q))? 2. Instead of return(fx and fx), mine is: return False if not self.isSameTree(p.left, q.left) else self.isSameTree(p.right, q.right) - this should be more efficient since if left nodes comparison are not equal then it will reach end of recursion earlier?
@hfchen5323
@hfchen5323 Күн бұрын
Great video but I have a question:Why using hashset instead of a regular list?
@user-th7cu9ll4j
@user-th7cu9ll4j Күн бұрын
Please someone correct me if I'm wrong, but can we just code return sort(s)==sort(t)?
@user-th7cu9ll4j
@user-th7cu9ll4j Күн бұрын
oh never mind, he covers it
@user-ny6tz2rb1r
@user-ny6tz2rb1r Күн бұрын
So key point here is if prefixsum%k=r and (prefixsum+x1+x2+•••••+xn)%k=r then undoubtedly x1+x2+•••••+xn is multiple of k
@GabrielCosta-to5xo
@GabrielCosta-to5xo Күн бұрын
Hashset*
@Gregoriobart
@Gregoriobart Күн бұрын
What's the difference between using set with add or a list with append? Wouldn't it be the same?
@ddshoo5282
@ddshoo5282 Күн бұрын
i just modelled it after the basic binary search solution lol: class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: l = 0 r = len(matrix) * len(matrix[0]) - 1 while l <= r: mid = (l + r) // 2 midRow = mid // len(matrix[0]) midCol = mid % len(matrix[0]) if matrix[midRow][midCol] > target: r = mid - 1 elif matrix[midRow][midCol] < target: l = mid + 1 else: return True return False
@raresgosman1735
@raresgosman1735 Күн бұрын
Nice touch with the George Michael @ 7:34
@Isaac-eh6uu
@Isaac-eh6uu Күн бұрын
Lmao the hat.
@ChargedOB
@ChargedOB Күн бұрын
Took me a long time to finally watch this video, but we have similar stories in some areas. Wanted to provide for family, no college grads in the tree, no father, 3 siblings. Two of which look up to me a lot. Have been doing software for about 10 years now and around the same time as you (early pandemic, late 2020) I just snapped under the stress and imposter syndrome of my work. I spent the next two years high as a kite trying to bury the stress and all I achieved was slowing my progress and building up my fear. So I quit that job ASAP, and instead of taking a break, accepted an even worse one. For the tenure of that employment I was vomiting, stressed, overwhelmed, and depressed. I had just relocated, buried a relative, and the job change were all a super storm for finishing me off. I rage quit last August 2023. I've now spent close to a year exercising and recuperating my mental health and reminding myself that my work ethic wasn't the problem, but the environments I landed in. Anyways I have an Amazon interview tomorrow and safe to say I am taking this all in before I accept the next one. Thanks for all you do, A brother in battle.
@po-shengwang5869
@po-shengwang5869 Күн бұрын
let me show you something.... still no explanation on the thought about how does this "reverse trick" come up with?
@aurkom
@aurkom Күн бұрын
``` def findMin(self, nums: List[int]) -> int: left = 0 right = len(nums) - 1 while (left < right): mid = (left+right)//2 if (nums[mid] <= nums[right]): right = mid else: left = mid+1 return nums[left] ```
@yusufnurwahid898
@yusufnurwahid898 Күн бұрын
I still don't understand for edge case where height[l] == height[r], why can either shift the left or right pointer solve the problem?
@yunijkarki9088
@yunijkarki9088 Күн бұрын
Even after the concept, i found it hard to code. Phew.
@jacinyan2348
@jacinyan2348 Күн бұрын
Wow!!
@johnj171
@johnj171 Күн бұрын
loveee youuuuu huge fan here
@mtrsoftwareservices
@mtrsoftwareservices Күн бұрын
Bruh, lose the hat! 🤠
@NeetCode
@NeetCode Күн бұрын
I can't, it's physically attached to my head
@WebDevMehta
@WebDevMehta Күн бұрын
@@NeetCode i thought it was bamboo copter
@WaldoTheWombat
@WaldoTheWombat Күн бұрын
This is my solution, but yours is better: def removeDuplicates(self, nums: List[int]) -> int: l = 0 r = 0 # or 1? while r < len(nums): while r+1 < len(nums) and nums[r] == nums[r+1]: r += 1 nums[l] = nums[r] r += 1 l += 1 return l
@meh4466
@meh4466 Күн бұрын
My solution is exactly similar to this but a bit more readable : min_req = 1 counter = len(nums)-2 while(counter >= 0): if(nums[counter] >= min_req): counter -= 1 min_req = 1 else: counter -= 1 min_req += 1 if min_req == 1: return True return False
@devakinandan23
@devakinandan23 Күн бұрын
7:02 - start of test case