2833. Furthest Point From Origin
Problem Statement
You are given a string moves
of length n
consisting only of characters 'L'
, 'R'
, and '_'
. The string represents your movement on a number line starting from the origin 0
.
In the ith
move, you can choose one of the following directions:
move to the left if
moves[i] = 'L'
ormoves[i] = '_'
move to the right if
moves[i] = 'R'
ormoves[i] = '_'
Return the distance from the origin of the furthest point you can get to after n
moves.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= moves.length == n <= 50
moves
consists only of characters'L'
,'R'
and'_'
.
Intuition
Links
Video Links
Approach 1:
Approach 2:
Approach 3:
Approach 4:
Similar Problems
Last updated