Simplified the approach with O(n) TC & O(1) SC 
IntuitionThe problem statement sounds bit confusing due to this lines
In the ith move, you can choose one of the following directions:move to the left if moves[
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem statement sounds bit confusing due to this lines
In the ith 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] = '_'


# Approach
<!-- Describe your approach to solving the problem. -->
So i have created two cases considering 
for max1 move to the left if moves[i] = '_'
for max2 move to the right if moves[i] = '_'

At the last returning
return Math.max(Math.abs(max1),Math.abs(max2));
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(n)$$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$$O(1)$$
![image.png](https://assets.leetcode.com/users/images/e6d529d1-0dd3-4128-8b52-6cbed844df72_1734683002.9800115.png)

# Code
```java []
class Solution {
    public int furthestDistanceFromOrigin(String moves) {
        //Two scenario we can get
        int max1=0;// Considering move to the left if moves[i] = 'L' or moves[i] = '_'
        int max2=0;// Considering move to the right if moves[i] = 'R' or moves[i] = '_'
        
        //Case 1: max1
        for(int i=0;i<moves.length();i++){
            if(moves.charAt(i)=='L' || moves.charAt(i)=='_'){
                max1=max1-1;
            }else if(moves.charAt(i)=='R'){
                max1=max1+1;
            }
        }
        //Case 2: max2
        for(int i=0;i<moves.length();i++){
            if(moves.charAt(i)=='R' || moves.charAt(i)=='_'){
                max2=max2+1;
            }else if(moves.charAt(i)=='L'){
                max2=max2-1;
            }
        }
        return Math.max(Math.abs(max1),Math.abs(max2));
    }
}
```
['Java']