#K74517. Balanced Parentheses Checker
Balanced Parentheses Checker
Balanced Parentheses Checker
You are given a string s
consisting of alphabetic characters and parentheses. Your task is to determine if the parentheses in the string are balanced.
A string is said to have balanced parentheses if every opening parenthesis (
has a matching closing parenthesis )
and the pairs are properly nested. For example, the string "(a + b)" has balanced parentheses while "(a + b" does not.
Note: The string may be empty, in which case it is considered balanced.
inputFormat
The input consists of a single line containing the string s
. The string may include alphabetic characters, spaces, and the characters '(' and ')'.
outputFormat
Print True
if the string has balanced parentheses, otherwise print False
.
(a + b)
True
</p>