LeetCode 32 - Longest Valid Parenthesis

Поделиться
HTML-код
  • Опубликовано: 12 дек 2024

Комментарии • 22

  • @vidhishah9154
    @vidhishah9154 3 года назад +3

    Your explanation is awesome. Can't understand why did you stop making videos. If possible please resume your work.

  • @LTZMSYAL
    @LTZMSYAL 2 года назад

    great job thank's that was clear!

  • @kewtomrao
    @kewtomrao 2 года назад

    Awesome explanation sir.
    Thanks for this!

  • @mikasaackerman2694
    @mikasaackerman2694 4 года назад +1

    Loved the explanation! You made it look so easy :)

  • @wanjohisamuel8547
    @wanjohisamuel8547 4 года назад

    Thanks man. This is so good.

  • @BryanAndradeNYC
    @BryanAndradeNYC 5 лет назад +1

    Thanks, this was very helpful!

  • @Destiny199623
    @Destiny199623 5 лет назад +1

    Thanks, it was helpful :)

  • @snugg1225
    @snugg1225 4 года назад

    Only thing that's a little confusing is 10:06
    What about the state of our stack reveals that we have nothing to pop? Because it's empty? Thanks.

    • @justanaverageguy4739
      @justanaverageguy4739 4 года назад

      if the top element is -1 (i.e : empty) than we just need to push the position into stack as its
      state depends on future character

  • @helloiam2mas
    @helloiam2mas 4 года назад +1

    Correct me if I am mistaken, but this test case will fail ')('.
    It checks first to see if s[I] == ')'. It does. Then it looks at the index of the top element (-1) and the s element @ that index. s[-1] == '('. So technically that check will succeed. Then it pops -1 off the stack. Then the stack is empty. When the stack is empty, the max function fails. I think you have add another check after the pop which checks if the stack is empty. If it is empty, then you simply add the current index to the stack and continue. This will handle cases where ')' parenthesis start the string.

    • @VinceLaw88
      @VinceLaw88 4 года назад +1

      I just checked ")", "(" and ")(" test cases. They all passed with output "0". You just need to make sure to check for the stack-top's value to make sure it is not "-1" such as:
      if(topStackValue != -1 && chars[topStackValue] == '(' && chars[i] == ')') {
      ...
      }

  • @rakshith3547
    @rakshith3547 5 лет назад

    It would be great if you could come up with Java code as it will be applicable to large number of audiance.

  • @tushartilwani9540
    @tushartilwani9540 4 года назад +1

    Was very difficult to follow you. How does this even work for this example: "((((())(((()"?

    • @educatorshub7860
      @educatorshub7860 4 года назад

      Tushar Tilwani
      ruclips.net/video/WZOPRISRfps/видео.html
      Go through this

  • @TheNealtt
    @TheNealtt 5 лет назад +1

    (y)

  • @whylifts
    @whylifts 3 года назад

    these 4 questions are the same, can be solved with one approach: ruclips.net/video/ic8JTuVckg0/видео.html, hope this helps.

  • @biswamohandwari6460
    @biswamohandwari6460 4 года назад

    Man please tell your Instagram I'd you are awesome in problem solving

  • @akshaydwivedi935
    @akshaydwivedi935 5 лет назад +2

    You should work on ur audio its just spoiling ur work man !