Clean Code | Easy O(N) | With Hints
Intuition:\nFrom already existing directions, which one is the greater one? If both of them are equal, add any one.\nThink of L as $-1$ and think of R as $+1$.\
# Intuition:\nFrom already existing directions, which one is the greater one? If both of them are equal, add any one.\nThink of **L** as $-1$ and think of **R** as $+1$.\nConsider them while calculating answer.\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 {\n    public int furthestDistanceFromOrigin(String moves) {\n        int cL=0, cR=0;\n        int n = moves.length();\n        int ans=0;\n        for(int i=0; i<n; i++) {\n            if(moves.charAt(i)==\'L\'){\n                cL++;\n            }\n            else if(moves.charAt(i)==\'R\') {\n                cR++;\n            }\n        }\n        \n        if(cL>cR) {\n            ans = cL-cR;\n        }\n        else {\n            ans = cR-cL;\n        }\n        \n        ans += (n-cR-cL);\n        \n        return ans;\n    }\n}\n```
['Array', 'Java']