Leetcode 1673. Find the Most Competitive Subsequence

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • • Monotone Stack (Leetco...
    leetcode.com/contest/weekly-c...

Komentáře • 14

  • @vidhishah9154
    @vidhishah9154 Před 3 lety +5

    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.

  • @bornbydawn
    @bornbydawn Před 3 lety +1

    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!

  • @editorera239
    @editorera239 Před 2 lety

    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

  • @aditya234567
    @aditya234567 Před 3 lety

    Thanks for the video. It would have been great if you chosen a better example where count would go to zero way too early

  • @rahulgarg6393
    @rahulgarg6393 Před 2 lety

    this helped me alot thanks to you

  • @harshsngh07
    @harshsngh07 Před 3 lety

    thanks for the video

  • @codingwithanonymous890

    superb explanation sir :)

  • @prathamanand1037
    @prathamanand1037 Před 3 lety

    thanks

  • @anishsuman1371
    @anishsuman1371 Před 2 lety

    Monotonic stack is mind blowing

  • @ajit5384
    @ajit5384 Před 3 lety

    Please solve it using BIT

  • @true_human_007
    @true_human_007 Před 2 lety

    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;
    }

  • @user-tu3hp3fz4k
    @user-tu3hp3fz4k Před 3 lety

    Thanks a lot for the explanation.