HackerRank Balanced Brackets Solution Explained - Java

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

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

  • @willynelsondawara1339
    @willynelsondawara1339 4 года назад +15

    I've never seen anyone so happy before while coding

  • @6957-c5k
    @6957-c5k 5 лет назад +28

    Nick looks like he is high on Hacker Rank

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

    When return value is "NO", you have should skipped the for loop.. example:
    (})()
    we found in the second index that it is not balanced..hence we need not check from third index to last

  • @edsonxrego2
    @edsonxrego2 9 месяцев назад

    Thank you!

  • @munazzainamulhaque8863
    @munazzainamulhaque8863 4 года назад +2

    It was a very optimistic solution...thanks!

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

    you're a legend on hacker rank

  • @lenabarlow
    @lenabarlow Год назад

    Can someone tell me where the actual String with the brackets was declared? Where is its value ?I made a screenshot but I cannot see it.

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

    Thank you Nick

  • @UncleDrew-69
    @UncleDrew-69 4 года назад

    Why does the leetcode solution fail one test case for this Hackerrank problem? Aren't they essentially the same problem?

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

    Great explaination thanks a lott dude

  • @Lucas.P.
    @Lucas.P. 3 года назад

    thanks

  • @ajaychowdarykandula2230
    @ajaychowdarykandula2230 3 года назад +1

    amazing nick!!!

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

    if the String passed is }}{{ then it will cause stack underflow because the code will try to pop out from the empty stack ?

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

      Wrong if the stack is empty it will return NO in line 19-20

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

    hey, small question.
    you could also solve this by checking like if its a palindrome no?

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

      No, because the string isn't necessarily symmetric

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

      @@luisphilipeAn example please?

    • @pranavnyavanandi9710
      @pranavnyavanandi9710 2 года назад +1

      Well, I got it.
      ()(( )) is balanced but not a palindromic string. Thanks.

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

      @@pranavnyavanandi9710 yeah, you got it. 💪

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

    Could I do this using arraylist?

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

    brother your pop operation is assigned as not equal to ,so how to pop the character when u return no

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

      Tushar Goyal the pop happens before the actual check. We assign it to pop_val first then check it against the character that is seen in the string. Negative logic is used because we are only returning and stopping the run if our expectations of the character are not met

  • @lifeofme3172
    @lifeofme3172 4 года назад +2

    It would have been nice to return boolean. But yes or no is fine too. Thanks for the explanation 👍

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

    Stack stack = new Stack() does not work with node.js, can you tell me what line of code should I use instead of this one?.
    Thank you.

    • @619frank
      @619frank 4 года назад

      let stack = [ ]

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

    🥰 thanks for that

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

    You are awesome!!

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

    You should have a good night sleep bruh.. yh I know it's 2021 LoL