Комментарии:
God damn, my head hurts hahaha
ОтветитьHad the sliding window part down, the maximum and minimum threw me off a bit but the formula is the part where I'm thinking "how the heck??"
ОтветитьAs you are moving pointer again to left when we found any fault
Isn't it is disturbing cpu cycle? Because it is making knot of pointers during computation
Can we optimize this knot ?
sir is it possible if you can explain the segment or fenwick tree approach for this problem?
ОтветитьNice explanation, may I know which blackboard you are using?
ОтветитьVery beautifully explained !
ОтветитьSuddenly my brain is not braining😂😂
ОтветитьThis is first time I see the window is going like a swing. That made me confusing(especially the double count & subtracton🥲). If I had never seen this algo my dumb brain could never figure out the soln.
Ответитьsir can i use priority queues to maintain min and max values so as to avoid the left movement of L pointer where i can update L pointer to the index choosen from the priority queues after checking the condition?
ОтветитьYour python does not submit on leetcode and provides wrong output. Kindly, please check
Ответитьcould explain why the n*(n+1)/2 come about?
ОтветитьI was with you until you start talking about moving L pointer.
Ответитьwhat an explanation!!!
ОтветитьTime to practice more sliding window problems 😢
ОтветитьThank you
Ответитьi think we can adjust the left pointer also simply by maintaining the index and updating the index if the same number occuring multiple times
ОтветитьMoving left pointer back to avoid duplicate was a bit tricky...
ОтветитьThis guy ❤
ОтветитьLoving the explanation Hating the problem
Ответитьwould maintaining a index whenever I update max help last wala update will be stored and my next L would be ind+1;
Ответитьgood explanation as always, many thanks
ОтветитьYour Python code in the link need minor enhancement. n = len(nums) should be used instead of right pointer to calculate the final number of subarrays to be addes outside the loop on line number 126. It should be win_size = n - left instead of win_size = right - left.
Ответитьthe python solution will give you a wrong answer. After finishing the loop, you can not use the right variable because the value is n-1
win_size = len(nums) - left
count += (win_size * (win_size + 1)) // 2
why don't you move the left pointer to right man its striaght forward and less complicated for explaining!
ОтветитьGood explanation Sir.
Ответитьwonderful explain
ОтветитьExcellent expalination, I too comeup with the exact approach but struggle to code it. Thanks man.
ОтветитьNice explanation. Thanks. Just one tiny bug: when moving back left, we need to ensure we are not moving out of the array
Ответитьthanks :)
Ответитьgreat call to include the complexity analysis! i came up with a similar solution but rejected it because i thought moving left pointer back would cause the complexity to become N-squared!
thanks :)
using deque makes it o(n) both time and space
Ответить