AlgoUniversity
  • Go Back
Discussion
String Matching :

Author

Akshay Sharma

Difficulty Level : Easy

Submissions : 3850

Asked In : Google

Marks :100

: 10 | : 62

Given a string of length N contains only parentheses, Scan it to see if it is well nested or not.

The String is said to be well nested if we can apply any maths equation within the given parentheses correctly or not.

If the string is well-nested return it as it otherwise makes some operation says addition and modification by choosing any index and opening or closing bracket or modifying the current bracket.

We are not concerned with the number of operations we performed.

Input

The first line of the test case contains an integer N the length of the string ($$$1 \le N \le 10^5$$$).

The second line contains the string S of length N.

Output

For each test case print a well-formed string

Example

Input
5
(()))
Output
(())()

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.