Weekly Contest 360||Java||Counting||Easy method
\n# PLEASE UPVOTE\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:0(n)\n Add your space complexity here,
\n# PLEASE UPVOTE\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:0(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int furthestDistanceFromOrigin(String moves) {\n        int l=0;\n        int r=0;\n        int empty=0;\n        for(int i=0;i<moves.length();i++){\n            if(moves.charAt(i)==\'L\'){\n                l++;\n            }\n            if(moves.charAt(i)==\'R\'){\n                r++;\n            }\n            if(moves.charAt(i)==\'_\'){\n                empty++;\n            }\n        }\n        if(l==0||r==0){\n            return moves.length();\n        }\n        if(l>=r){\n            return l+empty-r;\n        }\n        if(r>=l){\n            return r+empty-l;\n        }\n        return 0;\n        \n    }\n}\n```
['Counting', 'Java']