2025-08-21 17:31:03 +0300 MSK
Furthest Point From Origin
Links
Code
class Solution:
def furthestDistanceFromOrigin(self, moves: str) -> int:
cnt_left, cnt_right, cnt_any = 0, 0, 0
for char in moves:
if char == "L":
cnt_left += 1
elif char == "R":
cnt_right += 1
else:
cnt_any += 1
if cnt_right > cnt_left:
return cnt_right - cnt_left + cnt_any
return cnt_left - cnt_right + cnt_any