Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Exercise: Balanced Brackets

Sumit Rawal answered on May 16, 2023 Popularity 7/10 Helpfulness 1/10

Contents


More Related Answers

  • Python Program to check for balanced parentheses in an expression using stack class.
  • bracket balanced or not in python
  • balanced parentheses
  • balanced brackets in c++
  • balanced parentheses checker online
  • balanced parentheses checker online
  • Solution Review: Balanced Brackets
  • Determine if Brackets are Balanced
  • Algorithm check balanced parentheses

  • Exercise: Balanced Brackets

    0

    Problem Statement

    Given a string containing only square brackets, [], you must check whether the brackets are balanced or not. The brackets are said to be balanced if, for every opening bracket, there is a closing bracket.

    You will write your code in the check_balance() function, which returns True if the brackets are balanced and False if they are not.

    For an empty string, the function will return True.

    For the sake of simplicity, you can assume that the string will not contain any other characters.

    svg viewer

    Sample Input

    "[[[[][]]]]"

    Sample Output

    True

    Coding Challenge

    Take some time to figure out how this problem can be solved using loops. While this problem can be solved in other ways, you should try to use the loop properties.

    If you feel stuck, you can always refer to the solution review in the next lesson.

    Good luck! 

    Popularity 7/10 Helpfulness 1/10 Language python
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on May 16 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.