S is a string of capital
alphabets, parts of which may be enclosed in brackets ( ). S is an invalid
string if the brackets are nested. For example : AXB (YPT (COM)FTY) XUP is not
a valid string. Write a program to
(1) Check the validity of the input string.
(2) If the string is valid, output the given string omitting the portion enclosed in brackets.
(1) Check the validity of the input string.
(2) If the string is valid, output the given string omitting the portion enclosed in brackets.
For example : Input string :
COM(IP)PUTER IS JUNK (MONK) MACHINE
Output string : COMPUTER IS JUNK MACHINE
If the string is not valid, print the string and a message “Input string is not valid” and stop.
Output string : COMPUTER IS JUNK MACHINE
If the string is not valid, print the string and a message “Input string is not valid” and stop.