#K51502. Balanced Parentheses Checker
Balanced Parentheses Checker
Balanced Parentheses Checker
Given a string that may include lowercase letters and parentheses, determine whether the parentheses are balanced and properly nested. A string is considered balanced if every opening parenthesis (
has a corresponding closing parenthesis )
and the pairs are correctly ordered.
The input string is provided via stdin
, and your program should output either True
or False
to stdout
based on whether the string's parentheses are balanced.
inputFormat
The input consists of a single line containing a string which may include lowercase letters and parentheses. The string can be empty.
outputFormat
Output a single line: True
if the input string has balanced and properly nested parentheses, and False
otherwise.
a(b)c(d)
True
</p>