Furthest Point From Origin Problem

Furthest Point From Origin Problem — ExecCode Easy DSA Practice

Solve the Furthest Point From Origin problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a string moves of length n consisting only of characters 'L', 'R', and ''. Your task is to compute the required answer and return the distance from the origin of the furthest point you can get to after n moves. The string represents your movement on a number line starting from the origin 0. In the i^th move, you can choose one of the following directions: - move to the left if moves[i] = 'L' or moves[i] = '' - move to the right if moves[i] = 'R' or moves[i] = '_'.

Examples

Input {"moves": "_______R"}; Output 9. Input {"moves": "LRLR"}; Output 3. Input {"moves": "L___R"}; Output 5

Constraints

1 <= moves.length == n <= 50 moves consists only of characters 'L', 'R' and '_'.

Practice Furthest Point From Origin free on ExecCode. Browse DSA problems, topic map, and placement guides.