[TypeScript] 40ms Beats 100%
Approach\nl = count of "L"\nr = count of "R"\nk = count of "_"\nn = length of $moves$\nFurthest distance (f) = $|l-r|+k$\n$k=n-l-r$\nSo, $f =\n  \begin{cases}\n
# Approach\nl = count of "L"\nr = count of "R"\nk = count of "_"\nn = length of $moves$\nFurthest distance (f) = $|l-r|+k$\n$k=n-l-r$\nSo, $f =\n  \\begin{cases}\n    \\text{if }l>r,&l-r+k=l-r+(n-l-r)=n-2r\\\\\n    \\text{if }l \\leq r,&r-l+k=r-l+(n-l-r)=n-2l\n  \\end{cases}$\n\n# Complexity\n- Time complexity: $\\mathcal{O}(n)$\n- Space complexity: $\\mathcal{O}(1)$\n\n# Code\n```\nfunction furthestDistanceFromOrigin(moves: string): number {\n    let l = 0, r = 0, n = moves.length;\n    for (let i = 0; i < n; i++)\n        if (moves[i] === \'L\') l++\n        else if (moves[i] === \'R\') r++;\n    return n - 2 * (l > r ? r : l);\n};\n```
['String', 'TypeScript']