AlgoUniversity
  • Go Back
Discussion
Longest Matching Substring :

Author

Manas

Difficulty Level : Medium

Submissions : 59

Asked In : wipro

Marks :10

: 2 | : 0

Given a string of 0's and 1's. Find the longest substring which has equal number of 0's and 1's. If there are multiple such substrings with the same length, then output the substring which occurs first.

Input

The first line contains and integer n which denotes the size of the string. The next line contains a n length string of 0's and 1's

Output

A single string which corresponds to the longest substring with equal number of 0s and 1s.

Example

Input
11
11101011100
Output
01011100

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.