Furthest Distance from Origin – Beats 100% | Optimal Count-Based Solution 🚀
IntuitionThe problem involves calculating the furthest distance from the origin based on moves given in a string, where 'R' and 'L' represent right and left mov
# Intuition
The problem involves calculating the furthest distance from the origin based on moves given in a string, where 'R' and 'L' represent right and left moves, and '_' represents an unknown move that could be taken in any direction. The key idea is that the maximum distance is achieved by using all '_' moves in the direction that increases the net displacement from the origin.

# Approach
- Count the number of 'R' and 'L' moves to determine the net displacement.
- Count the number of '_' characters which represent the number of moves that can be optimally used.
- The furthest distance is then the absolute net displacement plus the number of '_' moves.

# Complexity
- **Time complexity:**  
  $$O(n)$$, where *n* is the length of the string, since we perform a single pass to count the characters.
  
- **Space complexity:**  
  $$O(1)$$, as only a fixed amount of extra space is used for the counters.

# Code
```python3 []
class Solution:
    def furthestDistanceFromOrigin(self, m: str) -> int:
        return m.count('_') + abs(m.count('R') - m.count('L'))

['Python3']