Balanced Paranthesis Coding Question — Asked in Google, Amazon

Problem Statement:

For a given a string expression containing only round brackets or parentheses, check if they are balanced or not. Brackets are said to be balanced if the bracket which opens last, closes first.

Input Format:

The first and the only line of input contains a string expression without any spaces in between.

Output Format:

The only line of output prints ‘true’ or ‘false’.

Sample Input 1 :

Sample Output 1 :

Sample Input 2 :

Sample Output 2 :

Explanation of Sample Input 2:


Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store