2833. Furthest Point From Origin Easy

@problem@discussion
#String#Counting



1/**
2 * [2833] Furthest Point From Origin
3 *
4 * 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.
5 * In the i^th move, you can choose one of the following directions:
6 * 
7 * 	move to the left if moves[i] = 'L' or moves[i] = '_'
8 * 	move to the right if moves[i] = 'R' or moves[i] = '_'
9 * 
10 * Return the distance from the origin of the furthest point you can get to after n moves.
11 *  
12 * <strong class="example">Example 1:
13 * 
14 * Input: moves = "L_RL__R"
15 * Output: 3
16 * Explanation: The furthest point we can reach from the origin 0 is point -3 through the following sequence of moves "LLRLLLR".
17 * 
18 * <strong class="example">Example 2:
19 * 
20 * Input: moves = "_R__LL_"
21 * Output: 5
22 * Explanation: The furthest point we can reach from the origin 0 is point -5 through the following sequence of moves "LRLLLLL".
23 * 
24 * <strong class="example">Example 3:
25 * 
26 * Input: moves = "_______"
27 * Output: 7
28 * Explanation: The furthest point we can reach from the origin 0 is point 7 through the following sequence of moves "RRRRRRR".
29 * 
30 *  
31 * Constraints:
32 * 
33 * 	1 <= moves.length == n <= 50
34 * 	moves consists only of characters 'L', 'R' and '_'.
35 * 
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/furthest-point-from-origin/
40// discuss: https://leetcode.com/problems/furthest-point-from-origin/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45    pub fn furthest_distance_from_origin(moves: String) -> i32 {
46        0
47    }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54    use super::*;
55
56    #[test]
57    fn test_2833() {
58    }
59}
60


Back
© 2025 bowen.ge All Rights Reserved.