Answered step by step
Verified Expert Solution
Question
1 Approved Answer
E . A 2 : Deepest Substring time limit per test 1 second memory limit per test 2 5 6 megabytes inputstandard input outputstandard output
E A: Deepest Substring
time limit per test second
memory limit per test megabytes
inputstandard input
outputstandard output
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started