Simple Count Method
Intuition\nThe code is trying to determine the furthest distance from the origin that a point can reach after following a series of moves. The moves are represe
# Intuition\nThe code is trying to determine the furthest distance from the origin that a point can reach after following a series of moves. The moves are represented by characters: `\'L\' `(move left), `\'R\'` (move right), and other characters (up or down movements). The goal is to calculate the maximum distance from the origin in terms of horizontal (left-right) and vertical (up-down) movements.\n\n# Approach\n1. Initialize three variables: lcount to keep track of the number of left movements, rcount to keep track of the number of right movements, and uscore to keep track of the number of vertical movements.\n2. Iterate through each character in the given moves string.\n3. If the character is `\'L\'`, increment the lcount variable.\n4. If the character is `\'R\'`, increment the rcount variable.\n5. Otherwise, increment the uscore variable for vertical movements.\n6. After iterating through all characters, calculate the absolute difference between lcount and rcount, which represents the horizontal distance.\n7. Add the vertical distance (uscore) to the horizontal distance to get the furthest distance from the origin that the point can reach.\nReturn the calculated furthest distance.\n\n# Complexity\n- Time complexity:\nThe code iterates through the moves string exactly once, performing constant time operations inside the loop. Thus, the time complexity of the code is `O(n)`, where n is the length of the moves string.\n\n- Space complexity:\nThe code uses three integer variables (lcount, rcount, and uscore) to keep track of counts, regardless of the length of the input string. Therefore, the space complexity of the code is `O(1)`, meaning it uses a constant amount of extra space regardless of the input size.\n\n# Code\n```\nclass Solution {\n    public int furthestDistanceFromOrigin(String moves) {\n        int lcount = 0, rcount =0, uscore = 0;\n        for(char i:moves.toCharArray()){\n            if(i == \'L\'){\n                lcount++;\n            } else if(i == \'R\'){\n                rcount++;\n            } else{\n                uscore++;\n            }\n        }\n        return Math.abs(lcount - rcount) + uscore;\n        \n    }\n}\n```
['String', 'Java']