Google-Developer-Student-Club-CCOEW / Competitive-Coding

7 stars 51 forks source link

Question 76 #185

Closed Mahi1901 closed 2 years ago

Mahi1901 commented 2 years ago

The Professor is facing the North. Tokyo is in trouble, and she is facing the South. Professor being her guardian angel wants to help her. So, The Professor will follow some instructions, given as a string S of length N, and will turn either left or right according to these instructions. He can save Tokyo only if after following a substring of instructions he will face in the same direction that Tokyo is facing. Will the Professor be able to save Tokyo?

Input Format The first line contains an integer T denoting the number of test cases. The T test cases then follow. The first line of each test case contains N. The second line contains a string that contains only 'L' and 'R', where 'L' represents left, and 'R' represents right.

Output Format For each test case, output "YES" if the Professor will be able to save Tokyo and "NO" otherwise.

Constraints1≤T≤100 2≤N≤10^5 The string S consists of uppercase characters 'L' and 'R' only. The sum of N over all test cases does not exceed 10^6.

Sample 1: Input 3 12 LRLRRRLRLLLL 2 LR 4 LRRL Output YES NO NO

AnnadaD commented 2 years ago

Annada Dash CCOEW Computer Engineering I would like to work on this issue Can you please assign me this issue

Kriti-2308 commented 2 years ago

Kritika Dubey Cummins college of engineering SY-IT I would like to work on this issue please assign it to me

Mahi1901 commented 2 years ago

I have assigned. Happy coding!

aditi3004 commented 2 years ago

HEY!!! This is Aditi Sharma(SY-C) MKSSS's CCOEW Computer Engineering

I want to work on this issue Can you assign this to me?

shreya2208 commented 2 years ago

Shreya Amritkar Cummins College of Engineering for Women, Pune Dept- Information Technology 3rd year I would like to work on this issue, can u pls assign it to me?

Kriti-2308 commented 2 years ago

Hi, I was just trying out the sample input and I think the output for the third test case should be "NO" because the professor will be facing north again by the end of it. Can you please check it out?

Mahi1901 commented 2 years ago

I have updated.

Kriti-2308 commented 2 years ago

i have sent the pull request