AlgoUniversity
  • Go Back
Discussion
Women Leading :

Author

Manas

Difficulty Level : Medium

Submissions : 239

Asked In : Cisco

Marks :10

: 4 | : 0

Shakuntala Devi once asked her students sitting in a lecture room. Determine the maximum number of seats occupied by students such that, number of consecutive seats occupied by women followed by number of consecutive seats occupied by mean are same.

Constraints :

1 <= R <= 10

1 <= S <= 10^5

Input

First line contains R, number of rows. Each line i (where 0<= i < R) of R subsequent lines contains a String.

Output

Return the integer which denotes the maximum length of continuous Women followed by Men, If it's not possible then return -1

Example

Input
2
WWMMMWMWWWMMMMWWWWWMMW
MMWWW
Output
6
-1

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.