Solving Meta's 2022 Most Asked Interview Question

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ก.ย. 2022
  • Meta's most asked coding interview question in 2022 is the problem "Minimum remove to make valid parentheses". The problem involves the use of a stack and set data structure.
    Check out my interview prep platform for learning the patterns!
    📢 Interview Prep Platform: algoswithmichael.com
    🎧 Join the community Discord: / discord
    💰 Support me on Patreon: / michaelmuinos
    🔗Follow me on LinkedIn: / michael-muinos
    📂Follow me on Github: github.com/MichaelMuinos
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 31

  • @hnkien
    @hnkien ปีที่แล้ว +22

    At 4:22, I think we need to pop from stack item 4, not item 2. Great video as usual!

    • @AlgosWithMichael
      @AlgosWithMichael  ปีที่แล้ว +3

      Woops, yea good catch

    • @goahnary
      @goahnary 8 หลายเดือนก่อน +2

      Right. That would be a queue. This works but I think a proper stack makes the most sense when you get to the final result as it removes unmatched pairs.

  • @correabuscar
    @correabuscar ปีที่แล้ว +3

    great explanation, loved it

  • @clot4764
    @clot4764 ปีที่แล้ว

    I haven’t seen yet but you are the best, just come from your triangle problem, love your videos ❤ please upload more❤

  • @DominikLoeffler1
    @DominikLoeffler1 27 วันที่ผ่านมา

    Great explanation! It should be emphasized that "set" here really means a hash table data structure (line 4 in the code). One might be tempted to use a set that's ordered, e.g. std::set in C++ which implements a binary search tree, rebalancing itself with each insert/erase/find. While the latter could be used and would still achieve correctness, it would do so at O(log(N)) vs. the former which does it at O(1). In other words, overall complexity with an ordered set would be much worse at O(N log(N)), after the usual dropping of constants

  • @MrMakemusicmike
    @MrMakemusicmike 4 หลายเดือนก่อน

    Very good.
    Clear information.

  • @hosseinbafekr6205
    @hosseinbafekr6205 ปีที่แล้ว

    Thanks for your clear explanation!

  • @furquan5974
    @furquan5974 8 หลายเดือนก่อน

    Excellent explanation 👍

  • @JackAbou2
    @JackAbou2 ปีที่แล้ว

    what platform did you use to code and run the solution? thanks great video BTW

  • @EMdragonKnight
    @EMdragonKnight 6 หลายเดือนก่อน

    Good explanation. Is converting the string to an array necessary? Strings in C#/Java also have indeces.

  • @Gangrelguy
    @Gangrelguy 22 วันที่ผ่านมา

    Add two closing parentheses on the end of the string being parsed and it breaks this algorithm.

  • @mikedelta658
    @mikedelta658 5 หลายเดือนก่อน

    thank you

  • @zaza.javakhishvili
    @zaza.javakhishvili 3 หลายเดือนก่อน

    I do not think that it will work on all string variations.

  • @correabuscar
    @correabuscar ปีที่แล้ว +4

    you say stack but I see (FIFO) queue at 4:20

    • @user-hd4sl
      @user-hd4sl 10 หลายเดือนก่อน

      It was a mistake he made

  • @destiny-fox1990
    @destiny-fox1990 9 หลายเดือนก่อน +2

    Theres a space o(1) solution thats expected

    • @pranavtiwari8682
      @pranavtiwari8682 8 หลายเดือนก่อน

      What is it?

    • @destiny-fox1990
      @destiny-fox1990 8 หลายเดือนก่อน

      @@pranavtiwari8682 look it up on LC discussion.

  • @SmokingNoir
    @SmokingNoir 7 หลายเดือนก่อน +3

    not how a stack works

  • @SC2Edu
    @SC2Edu 5 หลายเดือนก่อน

    Easy but fun

  • @sameer9368
    @sameer9368 ปีที่แล้ว +1

    Hi muinos....I am from India....please make more video.... 😎

  • @ravividap1227
    @ravividap1227 ปีที่แล้ว +1

    Why set and why not simple array?

    • @nitishjoshi2637
      @nitishjoshi2637 ปีที่แล้ว +1

      In case of an array, you will have to iterate over it to find if it contains the index, which becomes an O(N) operation. In case of a Set, you don't need to iterate and the operation is O(1).

    • @ravividap1227
      @ravividap1227 ปีที่แล้ว +1

      @@nitishjoshi2637 i did it with arrays 😀 declared an array of size input string length then store unique value at indexes to identify. I could still do it in order of N overall time complexity

    • @nitishjoshi2637
      @nitishjoshi2637 ปีที่แล้ว

      @@ravividap1227 Yes, the overall time complexity will not change, as the worst case would still be O(N). But if you are looking to optimize your code during interviews or otherwise, using a HashSet would definitely help 🙂

  • @rugvedwagh9434
    @rugvedwagh9434 ปีที่แล้ว

    First here mike

  • @vinayyelleti2714
    @vinayyelleti2714 ปีที่แล้ว

    stack.pop is char and how this is being added to set of integers..at line 16
    indexToRemove.add(stack.pop());