beats 90% runtime & 70% memory (java)
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int[] executeInstructions(int n, int[] startPos, String s) {
        int len = s.length();
        int[] arr = new int[len];

        for (int i = 0; i < len; i++) {
            int x = startPos[0];
            int y = startPos[1];

            int j = i;
            for (; j < len; j++) {
                char c = s.charAt(j);

                if (c == 'R' && y < n - 1) y++;
                else if (c == 'L' && y > 0) y--;
                else if (c == 'U' && x > 0) x--;
                else if (c == 'D' && x < n - 1) x++;
                else break;
            }

            arr[i] = j - i;
        }

        return arr;
    }
}
```
['Java']