Question: Question 1 . Write this code in c . The deepest substring of a string containing text in nested parenthesis is the substring which is
Question Write this code in c
The deepest substring of a string containing text in nested parenthesis is the substring which is enclosed in the maximum number of parenthesis. For example, the deepest substring of abcd is bc
Your program should take as input a string containing nested parenthesis and print out its deepest substring. If there is more than one substring at the deepest level then your program should output the first one. For example, on input abcde your program should output bc
You can assume the input string will contain at most characters that are only letters or parentheses ie no spaces and contains balanced parentheses every open parenthesis has a corresponding closing parenthesis You should read the input via standard input and print out nothing except the deepest substring followed by a newline.
Note. Your implementation must run in On operations where n is the length of the input string.
input: abcd
output: bc
input: abcde
output: bc
input: abcdef
output: cd
input: noparenthesis
output: noparenthesis
input:
output:
input: aabbccdd
output: aa
input: abcd
output: d
input: abcde
output: e
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
