"another day another problem" -anyone who works in tech
@ajaysaran6541Ай бұрын
Lot of time saved, Bcz of you. Thank you....
@madhu601Ай бұрын
Please pause while you explain
@alexandremarangonicostaАй бұрын
It is better to solve in O(n) by simple getting the 3 max and the 2 min in one pass.
@abdelrhmansayed3402 ай бұрын
thhxxx
@chiamakabrowneyes3 ай бұрын
wow great solution
@shriyapatil39234 ай бұрын
very precise solution. thanks
@amrabdelatyfathallah24874 ай бұрын
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.Rawat454 ай бұрын
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
@subee1284 ай бұрын
Thanks
@lesterdelacruz50885 ай бұрын
There is a dynamic programming solution that’s more optimal. O(n) time in exchange for more space O(n)
@subee1285 ай бұрын
Thank you very much
@subee1285 ай бұрын
Thank you very much
@kshitijpatil64885 ай бұрын
not correct
@adityahpatel5 ай бұрын
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.
@parviznorov54018 ай бұрын
Excuse me. I guess your code with stack doesn't work, because str objects does not support item assignment
@zerkarm75368 ай бұрын
good video
@tiantianliu59588 ай бұрын
Thank you! very clear explain.
@lightstrick9 ай бұрын
dude sounds depressed af
@MohSo1410 ай бұрын
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)
@deeppunkface799110 ай бұрын
This solution is combination of art and magic
@ultimatepotato71311 ай бұрын
Retarded question but thanks for explaining.
@megapyukumuku418511 ай бұрын
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.
@piotrzielonka198711 ай бұрын
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 Жыл бұрын
Great way to promote a channel
@user-pp3rv8xc7s Жыл бұрын
i want to see more of your videos
@dominic9714 Жыл бұрын
Can you upload a divide and conquer approach?
@user-sh9jf2ge6z Жыл бұрын
Cool solution! Thank you!
@user-fk1wo2ys3b Жыл бұрын
Thanks a lot, videos are very useful!!!
@memegalore257 Жыл бұрын
OmG start posting again we need you😢
@baaaaaaaaaaaaaaaaaaaaaaam Жыл бұрын
Nice this is probably the best explanation
@francescomangano1996 Жыл бұрын
Hi bro and thanks. Sliding Window Technique works also for an array with postive values and zeros ?
@msakshayakumar10 ай бұрын
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 Жыл бұрын
It was pretty easy, I don't undestand with it was to hard to me. Thanks for ypur explanation
@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 Жыл бұрын
You have a nested for loop. Your time complexity is certainly not O(n).
@Greenmarty10 ай бұрын
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 Жыл бұрын
[3, 5, 5]
@user-fk1wo2ys3b Жыл бұрын
Thanks a lot!!
@user-fk1wo2ys3b Жыл бұрын
Thanks for the great job! Sometimes slides are rotated too fast kzbin.info/www/bejne/bpmVhoKGeah6hq8
@user-fk1wo2ys3b Жыл бұрын
Thanks a lot for your help!!!
@onecodeman Жыл бұрын
you're welcome!
@masteradvisor594 Жыл бұрын
Can we use sliding window on first and last string
@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 Жыл бұрын
check the function declaration i think you add one parameter
@user-fk1wo2ys3b Жыл бұрын
THANKS A LOT MAN!!!
@onecodeman Жыл бұрын
🙏
@TuringTested01 Жыл бұрын
poor solution, O(1) space solution also exists, you've just explained the most trivial brute force solution
@gangstersofsona8486 Жыл бұрын
Can you share that here, brother?
@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 Жыл бұрын
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 Жыл бұрын
nicely explained, thanks!
@onecodeman Жыл бұрын
Thanks!
@mohamedbentaher6357 Жыл бұрын
Good explanation, much appreciated
@onecodeman Жыл бұрын
You are welcome!
@unknown30778 Жыл бұрын
Sir pls make vedio specifically graph and dp
@onecodeman Жыл бұрын
I will do it soon!
@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 Жыл бұрын
@@unknown30778 Did you watch my other videos? They are all for visual learners, I will Tanks for the support!
@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[:] = s[::-1]
@anusha3598 Жыл бұрын
IT DOES NOT PASS THE USE CASE :- [0,0,0,0] OR [0,0,0,0,0]