2833. Furthest Point From Origin
IntuitionThis is a beginner-friendly solution that focuses on tracking movements (L, R, and _) to calculate the furthest distance from the origin.ApproachThe ap
# Intuition
This is a beginner-friendly solution that focuses on tracking movements (L, R, and _) to calculate the furthest distance from the origin.

# Approach
The approach involves counting the number of 'L', 'R', and '_' characters in the given string. Each 'L' move decreases the position by 1, while each 'R' move increases it by 1. The underscores ('_') represent flexible moves that can act as either 'L' or 'R'. To maximize the absolute value of the final position, we strategically assign all underscores to either the left or right direction, whichever results in a greater absolute value. By calculating both possible outcomes and returning the maximum of the two, we ensure the farthest distance from the origin is achieved.

# Complexity
- Time complexity: O(n)


## - Space complexity: O(1)


# Code
```java []
class Solution {
    public int furthestDistanceFromOrigin(String moves) {
        int ans =0;
        int countL=0;
        int countR=0;
        int countU=0;
        for(char ch: moves.toCharArray()){
           if(ch=='L'){
            countL++;
           }
           if(ch=='R'){
            countR++;
           }
           if(ch=='_'){
            countU++;
           }
        }
        int a = Math.abs(countL*(-1)+countR+countU*(-1));
        int b = Math.abs(countL*(-1)+countR+countU*(1));
        return Math.max(a,b);

    }
}
```
['Java']