Комментарии:
Thanku bro. it helped me a lot
ОтветитьYou are fucking goated
ОтветитьNice explanation bro.
Ответитьguy has really great explanation skills.
Ответитьhey!!!!!!!!! thank you so much
ОтветитьLiked and Subscribed!
ОтветитьBest explanation of this question :)
Ответитьthank you so much u have helped me alot! it was similar to the XXLELOUCHXX problem
ОтветитьMy sorry ass, made for arrays and solved using stacks
SMALLER_LEFT, SMALLER RIGHT
GREATER LEFT, GREATER RIGHT
💀
Kacy thanks a lot for the solution it's so simple to understand, I was wondering how did you learn also that part of java I didn't see that BiFunction so cool
ОтветитьGreat explanation. Thanks. Subscribed.
ОтветитьThat was some rly rly good and clear explanations, helped me so much. Thanks heaps! You have gained a new subscriber!
ОтветитьYou gave the best explanation of this. I also loved that you didn’t create a NLE and PLE for each type of stack.
ОтветитьThank you very much for the explanation!
ОтветитьKabhi computer ke bahar bhi aja bhai
ОтветитьThank you so much for the video! Super clear! I have one question that how to handle the same values, like if we have two 4 in the array? Also, when we pop out the elements, when we use "<=", when we use "<"?
ОтветитьDamn man you are so good at explaining. Thank you for making these video!
ОтветитьKacy you're a beast at explaining these leetcode problems. Prepping for my Amazon interview coming up and you make it so easy to understand these concepts :D
ОтветитьGreat explanation man, subscribed. I was able to understand monotonic stacks through Sum of subarray mins, but the solution I studied involved finding prevLess elements and nextLess elements for each value nums[ i ].
Through your explanation, I was able to finally understand that when you pop an element in inc/dec monotonic stacks with respect to nums[ i ], you have positions of prev/next lesser/greater elements for the first popped element: i, and the new top of the stack! Crazy
You are my savior. Thank you so much!
ОтветитьThanks, helped me get the core idea behind the solution.
ОтветитьI aint the brightest guy, but this makes sense to me, love it!
Ответить@Kacy Thanks for great explanation. Can we use the same approach to find the number of subarrays, where (max_value - min_value) of each subarray is less than or equal to a threshold value? Appreciate any insights.
ОтветитьHow do you get the insight of calculating the number of sub-arrays by counting spots to the left and right and multiplying them? It seems to be counting all the possible combinations. Is there a formula to it or some material worth reading?
ОтветитьThis was a great explanation, thank you!!! Including my python3 implementation of Kacy's solution:
class Solution:
def subArrayRanges(self, nums: List[int]) -> int:
dec_stack = []
inc_stack = []
sum = 0
for i in range(len(nums) + 1):
sum += self.pushToStack(dec_stack, nums, i, dec=True) - self.pushToStack(inc_stack, nums, i, dec=False)
return sum
def pushToStack(self, stack, nums, i, dec):
sum = 0
while stack and (i == len(nums) or self.popFromStack(stack, nums, i, dec)):
pop_i = stack.pop()
prev_i = -1 if not stack else stack[-1]
sum += (pop_i - prev_i) * (i - pop_i) * nums[pop_i]
stack.append(i)
return sum
def popFromStack(self, stack, nums, i, dec):
# Return True if we need to pop from the stack to push the next index, else return False
return (nums[stack[-1]] < nums[i] and dec) or (nums[stack[-1]] > nums[i] and not dec)
Nice!
ОтветитьOne of the cleanest explanations for this problem. Can you also do 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit ?
ОтветитьGreat videos, keep it up!
ОтветитьI cannot resist appreciating you. You explain concepts very beautifully and patiently. : Respect++ : And write a damn clean code.
ОтветитьThanks man!
Ответитьnice explanation
ОтветитьI like every leetcode video you made. The explanations are quite clear. Thanks!
Ответить