Implement Queue using Stacks (LeetCode 232) | Side by side demo and diagrams

Sdílet
Vložit
  • čas přidán 11. 09. 2024

Komentáře • 15

  • @manojtate9604
    @manojtate9604 Před 3 měsíci +2

    Whenever I see your video related to DSA, I am satisfied with the concept.

  • @srushtikale7455
    @srushtikale7455 Před měsícem

    All your explanations are just best

  • @GAGGZz
    @GAGGZz Před 7 měsíci +2

    please make a playlist on Stack, queue, HashTables tries etc. as your teaching is awesome please continue your ds playlist

    • @nikoo28
      @nikoo28  Před 6 měsíci +1

      there are problems available on stacks and queues, just not in a playlist...will do that eventually :)

    • @adityajain3451
      @adityajain3451 Před 2 měsíci

      @@nikoo28 sir please make a playlist so helpful

  • @sdkaraarslan
    @sdkaraarslan Před 6 měsíci

    nice explanation with visuals and clear understanding, love this.

  • @user-um3vb7eu4k
    @user-um3vb7eu4k Před 7 měsíci

    Great explanation sir ❤👍

  • @Blackswordsman28476
    @Blackswordsman28476 Před 7 měsíci +1

    You have playlists on all other data structures
    Can you make a playlist on stacks & queues too?

    • @nikoo28
      @nikoo28  Před 6 měsíci

      i will try to find more problems that are explicitly on stacks and queues.

  • @ousmanbah10
    @ousmanbah10 Před 3 měsíci

    He is the best

  • @sonuanand167
    @sonuanand167 Před 5 měsíci

    nice explanation..... please make playlist for linked-list.. lot's of people are struggling in linked-list..
    Thanks!

    • @nikoo28
      @nikoo28  Před 5 měsíci

      did you already check this out: czcams.com/play/PLFdAYMIVJQHN6J5-OCh7pbG0o8WHC9so3.html

  • @limitless6189
    @limitless6189 Před 4 měsíci

    wonderfull broo

  • @sumitraj6878
    @sumitraj6878 Před 2 měsíci +1

    class MyQueue {
    private Stack input;
    private Stack output;
    public MyQueue() {
    this.input = new Stack();
    this.output = new Stack();
    }
    public void push(int x) {
    input.push(x);
    }
    public int pop() {
    if (!output.isEmpty())
    return output.pop();
    while(!input.isEmpty()){
    output.push(input.pop());
    }
    return output.pop();
    }
    public int peek() {
    if (output.isEmpty())
    while (!input.isEmpty())
    output.push(input.pop());
    return output.peek();
    }
    public boolean empty() {
    return (input.isEmpty() && output.isEmpty());
    }
    }
    // thank me later!

  • @huyuzhong9849
    @huyuzhong9849 Před 7 měsíci

    very interesting.