0.4 Dance Moves
(RankList for this Question)
Score: 10pts
Time Limit: 2.00 sec
Rishab has to prepare for a dance wherein he has to return to his initial place after all the steps. There are only 4 steps - F(Forward), B(Backward), L(Left), R(Right). Given is a string containing the steps sequence. You have to determine whether after completing all the given steps Rishab will return to his original position or not.

Constraints
\(1 \leq ( \) Length of the string\( ) \leq 10^{4}\)

Input Format
Input will be a single string which contains the sequence of steps

Output Format
Print ‘YES’ if Rishab has returned to his original position, else ‘NO’

Example 1
Input:
LR

Output:
YES

Explanation:
Rishab moves left once, and then right once. All steps have the same magnitude, so Rishab ended up at his initial position. Therefore, we print YES.

Example 2
Input:
FFB

Output:
NO

Explanation:
Rishab moves forward twice and backward once. He ends up one "step" in front of the origin. We print NO because it is not at his initial position.

Log In to solve the Question