C++ O(N)
Connect with me on LinkedIn: https://www.linkedin.com/in/abhay5349singh/\n\nApproach :\n since we want to move farthest from origin, so either we consider all "
**Connect with me on LinkedIn**: https://www.linkedin.com/in/abhay5349singh/\n\n**Approach :**\n* since we want to move farthest from origin, so either we consider all "_" as Left or Right\n\n```\nclass Solution {\npublic:\n    int furthestDistanceFromOrigin(string moves) {\n        int n=moves.length();\n        \n        int l=0, r=0;\n        for(int i=0;i<n;i++){\n            if(moves[i]==\'L\' || moves[i]==\'_\'){\n                l--;\n            }else{\n                l++;\n            }\n            \n            if(moves[i]==\'R\' || moves[i]==\'_\'){\n                r++;\n            }else{\n                r--;\n            }\n        }\n        \n        if(l<0) l *= -1;\n        if(r<0) r *= -1;\n\t\t\n        return max(l,r);\n    }\n};\n```\n\n**Do upvote if it helps :)**
['C++']