Tap here to switch tabs
Problem
Submissions

Problem: Furthest Point From Origin

med
30 min
Try to solve the Furthest Point From Origin problem.

Statement

You are given a string moves of length n consisting of the characters 'L', 'R', and '_'. The string represents your movement on a number line starting from the origin 00.

In each step:

  • If the character is 'L', you move 11 unit to the left.

  • If the character is 'R', you move 11 unit to the right.

  • If the character is '_', you may choose to move 11 unit to either the left or the right.

Return the maximum distance from the origin you can reach after completing all n moves.

Constraints:

  • 1≤1 \leq moves.length =‘n‘≤50= `n` \leq 50

  • moves consists only of the characters 'L', 'R', and '_'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Furthest Point From Origin

med
30 min
Try to solve the Furthest Point From Origin problem.

Statement

You are given a string moves of length n consisting of the characters 'L', 'R', and '_'. The string represents your movement on a number line starting from the origin 00.

In each step:

  • If the character is 'L', you move 11 unit to the left.

  • If the character is 'R', you move 11 unit to the right.

  • If the character is '_', you may choose to move 11 unit to either the left or the right.

Return the maximum distance from the origin you can reach after completing all n moves.

Constraints:

  • 1≤1 \leq moves.length =‘n‘≤50= `n` \leq 50

  • moves consists only of the characters 'L', 'R', and '_'.