Skip to content

Latest commit

 

History

History
24 lines (14 loc) · 727 Bytes

balanced_brackets.md

File metadata and controls

24 lines (14 loc) · 727 Bytes

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.

image

Sample Input

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

Sample Output

True