HackerRank - Balanced Brackets | Full solution with examples and visuals | Study Algorithms

Поділитися
Вставка
  • Опубліковано 31 січ 2025

КОМЕНТАРІ • 17

  • @jax8471
    @jax8471 6 місяців тому

    I am so happy I came across your channel and I am surprised to see you don't have more likes on this video! This is the best explanation I've come across for solving this problem. I love how you draw out what the data structures look like at each iteration of the loop, and you use of color! I'm a visual learner so this was a huge help to me! :) I've subscribed and am looking forward to watching more of your videos!
    Thank you for this, it truly helped me out!

  • @NiteshSachde
    @NiteshSachde 2 місяці тому

    Really underrated channel! excellent explanation

    • @nikoo28
      @nikoo28  2 місяці тому

      Glad you like them!

  • @akulahemasanthoshi2182
    @akulahemasanthoshi2182 Рік тому +3

    2nd approach was like boom... nice explanation

  • @pavankumarpadamati8606
    @pavankumarpadamati8606 Рік тому +1

    Nice explanation 😊

  • @bittujacob8776
    @bittujacob8776 3 роки тому

    Very clear explanation! i wish you best bro

  • @huonglan2725
    @huonglan2725 Рік тому

    so helpful, thank you so much

  • @vinothiniseenivasan1502
    @vinothiniseenivasan1502 2 роки тому

    clear explanation ...thank u

  • @tirmuladhanikonda699
    @tirmuladhanikonda699 2 роки тому

    Thank you sir. Nice explanation

  • @taherkp7321
    @taherkp7321 3 роки тому

    Excellent explanation.

  • @rahulchandran6482
    @rahulchandran6482 2 роки тому

    Loved it

  • @rohitsaka
    @rohitsaka 3 роки тому +2

    This was asked in HACKERRANK JAVA CERTIFICATION :
    Can you please explain me how this works !
    Given a list of strings of bracket characters: {}(), the string of brackets is balanced under the following conditions:It is the empty string.If strings a and b are balanced, then ab is balanced.If string a is balanced, then (a) and {a} are balanced. Write a class that determines whether the brackets in each string are balanced and returns true if the string is balanced, or false if it is not. Example 0 s = [ "{}()", "{()}", "({()})" ] s[0] exhibits condition 2 above. "{}" and "()" are balanced, so "{}()" is balanced. Return true.s[1] exhibits condition 3 above. "()" is balanced, so "{()}" is balanced. Return true.s[2] exhibits condition 3 above. "()" is balanced, so "{()}" is balanced and "({()})" is balanced. Return true.

    • @nikoo28
      @nikoo28  3 роки тому +1

      This problem is very much similar to the one I have discussed in the video. Each array element is a string that you need to check for balanced brackets.

    • @rohitsaka
      @rohitsaka 3 роки тому

      @@nikoo28 can you please provide me solution if possible.

    • @nikoo28
      @nikoo28  3 роки тому +1

      @@rohitsaka it is exactly the same code, just start a for loop with each string in the array and call the function I have used. You should be able to solve it.

  • @harshithanm6045
    @harshithanm6045 3 роки тому

    2nd approch ❤

  • @maximilianomaro6230
    @maximilianomaro6230 Рік тому

    Hi Nikhil, before to watch your explanation I tried the stack method in javascript, I used a loop and switch method but I think I did something wrong because it didn´t work.
    However, in the very long strings, where you need a very large stack, should it work fine?
    I´ve used a counter too, like this:
    { 'A': 0, 'B': 0, 'C': 0}
    but you need to store the order too... so it doesn´t work.
    And, what happens if we need to exclude other characters, for example { a + ( b - C) * (a /c) }; we can´t check this except that we removes all characters !== ( || ) || [ || ] || { || }
    Have a nice day!