After your explanation I was able to code it by myself and previously I thought monotonous stack is something tough, but you made it pretty easy. Liked the video and already a subscribed user.
Great explanation and approach. Specifically liked the part that you approached it from the elements remaining to remove which is much simpler and cleaner to understand than elements already in stack and elements left in the array after the current element. Liked and subscribed!
sir monotonic stack mei stack ki jageh vector hi use kre kya kyuki while using stack last mei stack elements ko vector mei push krate samay tle aara BTW thanks for suggesting to use vector this was saviour
After your explanation I was able to code it by myself and previously I thought monotonous stack is something tough, but you made it pretty easy. Liked the video and already a subscribed user.
thanks a lot Vidhi
Great explanation and approach. Specifically liked the part that you approached it from the elements remaining to remove which is much simpler and cleaner to understand than elements already in stack and elements left in the array after the current element. Liked and subscribed!
Thanks a lot ❤️
sir monotonic stack mei stack ki jageh vector hi use kre kya kyuki while using stack last mei stack elements ko vector mei push krate samay tle aara
BTW thanks for suggesting to use vector this was saviour
Thanks for the video. It would have been great if you chosen a better example where count would go to zero way too early
this helped me alot thanks to you
thanks for the video
superb explanation sir :)
thanks
Monotonic stack is mind blowing
Please solve it using BIT
public int[] mostCompetitive(int[] nums, int k) {
Stack stack = new Stack();
int[] ans = new int[k];
for(int i = 0; i < nums.length; i++) {
while(!stack.isEmpty() && nums[i] < stack.peek() && (nums.length - i + stack.size()) > k) stack.pop();
if (stack.size() < k) ans[stack.size()] = nums[i];
stack.push(nums[i]);
}
return ans;
}
Thanks a lot for the explanation.