Answered step by step
Verified Expert Solution
Link Copied!

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. A2: Deepest Substring
time limit per test1 second
memory limit per test256 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 a+((b+c)+d) is b+c.
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 a+((b+c)+(d+e)) your program should output b+c.
You can assume the input string will contain at most 1000 characters that are only letters or parentheses (i.e., 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
O(n)
operations where
n
is the length of the input string.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago