Easy C++ solution in O(n) and O(1) space
Intuition\nLeft moves can cancel the right moves and vice versa.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nJust keep the coun
# Intuition\nLeft moves can cancel the right moves and vice versa.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nJust keep the count of left moves, right moves and the null moves.\nAnswer will be number of null moves + abs(l-r)\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int furthestDistanceFromOrigin(string moves) {\n        int l=0,r=0,s=0,i,n=moves.length();\n        for(i=0;i<n;i++){\n            if(moves[i]==\'L\') l++;\n            else if(moves[i]==\'R\') r++;\n            else if(moves[i]==\'_\') s++;\n        }\n\n        int ans;\n        ans=s+abs(l-r);\n        return ans;\n    }\n};\n```
['C++']