Пікірлер
@whatdoweknow7336
@whatdoweknow7336 2 сағат бұрын
Excellent one!
@mathiasrivera6550
@mathiasrivera6550 7 күн бұрын
"another day another problem" -anyone who works in tech
@ajaysaran6541
@ajaysaran6541 Ай бұрын
Lot of time saved, Bcz of you. Thank you....
@madhu601
@madhu601 Ай бұрын
Please pause while you explain
@alexandremarangonicosta
@alexandremarangonicosta Ай бұрын
It is better to solve in O(n) by simple getting the 3 max and the 2 min in one pass.
@abdelrhmansayed340
@abdelrhmansayed340 2 ай бұрын
thhxxx
@chiamakabrowneyes
@chiamakabrowneyes 3 ай бұрын
wow great solution
@shriyapatil3923
@shriyapatil3923 4 ай бұрын
very precise solution. thanks
@amrabdelatyfathallah2487
@amrabdelatyfathallah2487 4 ай бұрын
can i ask question in sliding window in excatly this part : # Expand sliding window if total < k: end += 1 if end == len(nums): break total += nums[end] this snippet of code should be like this: # Expand sliding window if total < k: if end == len(nums): break end += 1 total += nums[end] because imagine if we have start pointer anywhere in array and end on element previous last one and total < k: so we need to expand so we increase end pointer by one and if we check first the condition of end == len(nums) will be true and it will break loop and return counter for example = 1 but if we check first when end on element previous last one the condition will be false and we increase end pointer by one and total will change and it will loop again and check if total > k or total == k or total < k lets say it will be total becomes equal to k it will increase counter by one and shrink window and it will break the loop after this and correct for me if iam wrong
@Aditya.Rawat45
@Aditya.Rawat45 4 ай бұрын
Thanks a lot for this, i just wanted to ask how do you find such patterns? Like how did you come to find out the step = 2 * rows -2 I just want to know the thought process so that i could practice more questions like this with the right approach
@subee128
@subee128 4 ай бұрын
Thanks
@lesterdelacruz5088
@lesterdelacruz5088 5 ай бұрын
There is a dynamic programming solution that’s more optimal. O(n) time in exchange for more space O(n)
@subee128
@subee128 5 ай бұрын
Thank you very much
@subee128
@subee128 5 ай бұрын
Thank you very much
@kshitijpatil6488
@kshitijpatil6488 5 ай бұрын
not correct
@adityahpatel
@adityahpatel 5 ай бұрын
Why are you starting from 0 and ending at n instead of (n-1)? No list/array starts from 0th element and ends at nth element. It always ends at (n-1)th element. so why have you done this? Going from 0 to n instead of 0 to (n-1) is not intuitive at all. I cannot believe this is intuitive to you. you must have memorized this.
@parviznorov5401
@parviznorov5401 8 ай бұрын
Excuse me. I guess your code with stack doesn't work, because str objects does not support item assignment
@zerkarm7536
@zerkarm7536 8 ай бұрын
good video
@tiantianliu5958
@tiantianliu5958 8 ай бұрын
Thank you! very clear explain.
@lightstrick
@lightstrick 9 ай бұрын
dude sounds depressed af
@MohSo14
@MohSo14 10 ай бұрын
Thanks for your video! Just one thing, in the worse case scenario we would have four letters for digits 7 and 9, so the time comlexity would be O(4^n)
@deeppunkface7991
@deeppunkface7991 10 ай бұрын
This solution is combination of art and magic
@ultimatepotato713
@ultimatepotato713 11 ай бұрын
Retarded question but thanks for explaining.
@megapyukumuku4185
@megapyukumuku4185 11 ай бұрын
The first solution is wrong. It will miss cases where the target could be the sum of the same number twice, if it isn't the first number. You got lucky with the test cases in your example because you are using j from 1..len(nums) instead of 0..len(nums). You should instead be doing j in range (i+1, len(nums)) to search all of the numbers further down in the array. This is in addition to the issues other people have brought up with the third solution.
@piotrzielonka1987
@piotrzielonka1987 11 ай бұрын
I believe that complexity of the third one is O(n*(n/2)), as you have to iterate by 1 element until you get to the right number, and expected/average number of elements to investigate is n/2. To have O(n*log(n)) you would have to divide the search space by 2 on each iteration, while here you divide search space by 2 only on the first iteration.
@Poodrdt
@Poodrdt Жыл бұрын
Great way to promote a channel
@user-pp3rv8xc7s
@user-pp3rv8xc7s Жыл бұрын
i want to see more of your videos
@dominic9714
@dominic9714 Жыл бұрын
Can you upload a divide and conquer approach?
@user-sh9jf2ge6z
@user-sh9jf2ge6z Жыл бұрын
Cool solution! Thank you!
@user-fk1wo2ys3b
@user-fk1wo2ys3b Жыл бұрын
Thanks a lot, videos are very useful!!!
@memegalore257
@memegalore257 Жыл бұрын
OmG start posting again we need you😢
@baaaaaaaaaaaaaaaaaaaaaaam
@baaaaaaaaaaaaaaaaaaaaaaam Жыл бұрын
Nice this is probably the best explanation
@francescomangano1996
@francescomangano1996 Жыл бұрын
Hi bro and thanks. Sliding Window Technique works also for an array with postive values and zeros ?
@msakshayakumar
@msakshayakumar 10 ай бұрын
doesn't seem like it because we move the start index once total == sum. maybe if we change the logic to: if total greater than K, then move the start index, we could make it work?
@Pkroc138
@Pkroc138 Жыл бұрын
It was pretty easy, I don't undestand with it was to hard to me. Thanks for ypur explanation
@user-sh7hs8qw3c
@user-sh7hs8qw3c Жыл бұрын
你好冒昧請教你,這串代碼,他有個BUG,無法正確地回答出head=[1,1,2,1] 請問你能指出她錯誤的地方嗎 class Solution: def isPalindrome(self, head: Optional[ListNode]) -> bool: #空節點直接返回True if not head : return True #初始化reverse_link reverse_link=None cur = head while cur: #記錄下一個 next_node=cur.next cur.next=reverse_link #更新標頭 reverse_link=cur cur = next_node while reverse_link and head: if reverse_link.val != head.val: return False reverse_link = new_link.next head = head.next return True
@grachtl296
@grachtl296 Жыл бұрын
You have a nested for loop. Your time complexity is certainly not O(n).
@Greenmarty
@Greenmarty 10 ай бұрын
In fact it is. Despite having nested loops, each loop is not iterating all of n elements. Instead each loop only goes through n/numRows of elements. In other words each element is only iterated once. Thus O(n).
@markomaricofficial
@markomaricofficial Жыл бұрын
[3, 5, 5]
@user-fk1wo2ys3b
@user-fk1wo2ys3b Жыл бұрын
Thanks a lot!!
@user-fk1wo2ys3b
@user-fk1wo2ys3b Жыл бұрын
Thanks for the great job! Sometimes slides are rotated too fast kzbin.info/www/bejne/bpmVhoKGeah6hq8
@user-fk1wo2ys3b
@user-fk1wo2ys3b Жыл бұрын
Thanks a lot for your help!!!
@onecodeman
@onecodeman Жыл бұрын
you're welcome!
@masteradvisor594
@masteradvisor594 Жыл бұрын
Can we use sliding window on first and last string
@user-fk1wo2ys3b
@user-fk1wo2ys3b Жыл бұрын
Faced strange error , running it on Leetcode, cant fix it TypeError: Solution.expandAroundTheCenter() takes 3 positional arguments but 4 were given oddPalindrome = self.expandAroundTheCenter(s, i-1, i+1)
@onecodeman
@onecodeman Жыл бұрын
check the function declaration i think you add one parameter
@user-fk1wo2ys3b
@user-fk1wo2ys3b Жыл бұрын
THANKS A LOT MAN!!!
@onecodeman
@onecodeman Жыл бұрын
🙏
@TuringTested01
@TuringTested01 Жыл бұрын
poor solution, O(1) space solution also exists, you've just explained the most trivial brute force solution
@gangstersofsona8486
@gangstersofsona8486 Жыл бұрын
Can you share that here, brother?
@Brosales1414
@Brosales1414 Жыл бұрын
Hello, can you explain why we check if root <= prevN? you said in the video that b/c stack uses LIFO(last in first out) that we can use that to our advantage by checking for root <= prevN. Sorry Im very new to this so I'm trying too understand the reason behind every step
@onecodeman
@onecodeman Жыл бұрын
Hi, if root <= prevN help us to Check if node's value that we pop from the stack is greater than or equal to previous value.
@ahmedaj2000
@ahmedaj2000 Жыл бұрын
nicely explained, thanks!
@onecodeman
@onecodeman Жыл бұрын
Thanks!
@mohamedbentaher6357
@mohamedbentaher6357 Жыл бұрын
Good explanation, much appreciated
@onecodeman
@onecodeman Жыл бұрын
You are welcome!
@unknown30778
@unknown30778 Жыл бұрын
Sir pls make vedio specifically graph and dp
@onecodeman
@onecodeman Жыл бұрын
I will do it soon!
@unknown30778
@unknown30778 Жыл бұрын
@@onecodeman also pls focus more about visual explanation not the code because most of us have different language but still I want to see because of visual explanation ... Thankyou .. ☺️
@onecodeman
@onecodeman Жыл бұрын
​@@unknown30778 Did you watch my other videos? They are all for visual learners, I will Tanks for the support!
@unknown30778
@unknown30778 Жыл бұрын
@@onecodeman yess i am continuously watching your vedios also suggesting to all my friends because your vedios length to small and effective ..
@s__c1358
@s__c1358 Жыл бұрын
s[:] = s[::-1]
@anusha3598
@anusha3598 Жыл бұрын
IT DOES NOT PASS THE USE CASE :- [0,0,0,0] OR [0,0,0,0,0]
@onecodeman
@onecodeman Жыл бұрын
Check again!