My straightforward N^2 approach in java by just simulating the given process
\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        if (s == null || s.length() == 0) {\n            return new
```\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        if (s == null || s.length() == 0) {\n            return new int []{};\n        }\n        int length = s.length();\n        int [] possibleMove = new int [length];\n        for (int i = 0; i < length; i++) {\n            int countOfPossibleMove = 0;\n            int startingRow = startPos[0];\n            int startingCol = startPos[1];\n            for (int j = i; j < length; j++) {\n                char ch = s.charAt(j);\n                if (ch == \'R\') {\n                    if (startingCol + 1 >= n) {\n                        break;\n                    }\n                    startingCol += 1;\n                }\n                else if (ch == \'L\') {\n                    if (startingCol - 1 < 0) {\n                        break;\n                    }\n                    startingCol -= 1;\n                }\n                else if (ch == \'U\') {\n                    if (startingRow - 1 < 0) {\n                        break;\n                    }\n                    startingRow -= 1;\n                }\n                else if (ch == \'D\') {\n                    if (startingRow + 1 >= n) {\n                        break;\n                    }\n                    startingRow += 1;\n                }\n                countOfPossibleMove += 1;\n            }\n            possibleMove[i] = countOfPossibleMove;\n        }\n        return possibleMove;\n    }\n}\n```
['Java']