Simple Java Solution | O(n) Time| O(1) Space | Please UPVOTE
Problem Description\n\nYou are given a string moves representing a series of moves. Each move can be either "L" (move one step left), "R" (move one step right),
# Problem Description\n\nYou are given a string `moves` representing a series of moves. Each move can be either "L" (move one step left), "R" (move one step right), or a blank space (stay in the same position). Your task is to find the furthest distance from the origin (position 0) that can be achieved by performing these moves.\n\n# Intuition\n\nThis problem involves interpreting a series of moves to determine the final position. The intuition here is to keep track of the changes in position caused by "L" and "R" moves while counting the number of blank spaces. The furthest distance from the origin can be calculated as the absolute sum of "L" and "R" moves, plus the count of blank spaces.\n\n# Approach\n\nTo efficiently solve this problem, we can follow this approach:\n1. Initialize variables `countBlank` to 0 and `sum` to 0. `countBlank` will keep track of the count of blank spaces, and `sum` will keep track of the net change in position due to "L" and "R" moves.\n2. Iterate through each character in the `moves` string:\n   - If the current character is "L," increment `sum` by 1 to represent moving one step left.\n   - If the current character is "R," decrement `sum` by 1 to represent moving one step right.\n   - If the current character is a blank space, increment `countBlank` to count the number of blank spaces.\n3. After processing all moves, calculate the furthest distance from the origin as `Math.abs(sum) + countBlank`. Taking the absolute value of `sum` ensures that we consider the net displacement, regardless of whether it\'s to the left or right.\n4. Return the calculated furthest distance as the result.\n\n# Complexity Analysis\n\n- Time complexity: O(n), where `n` is the length of the `moves` string. We iterate through the string once.\n- Space complexity: O(1), as we use only a constant amount of additional space for variables.\n\nThis efficient approach computes the furthest distance from the origin by interpreting the given moves correctly.\n\nShare this clever solution with your fellow LeetCode enthusiasts and help them master the art of tracking positions based on sequences of moves. Happy coding!\n\n\n# Code\n```\nclass Solution {\n    public int furthestDistanceFromOrigin(String moves) {\n        int countBlank = 0;\n        int sum = 0;\n        for(int i=0;i<moves.length();i++){\n            if(moves.charAt(i) == \'L\'){\n                sum++;\n            }\n            else if(moves.charAt(i) == \'R\'){\n                sum--;\n            }\n            else{\n                countBlank++;\n            }\n        }\n        return Math.abs(sum) + countBlank;\n        \n    }\n}\n```
['Java']