Simple Java Solution
\nclass Solution {\n    public int execute(int n, int[] startPos, String s) {\n        int initialX = startPos[0];\n        int initialY = startPos[1];\n       
```\nclass Solution {\n    public int execute(int n, int[] startPos, String s) {\n        int initialX = startPos[0];\n        int initialY = startPos[1];\n        int ans = 0;\n        for(int i=0;i<s.length();i++) {\n            if(s.charAt(i) == \'R\')\n                initialY++;\n            if(s.charAt(i) == \'L\')\n                initialY--;\n            if(s.charAt(i) == \'U\')\n                initialX--;\n            if(s.charAt(i) == \'D\')\n                initialX++;\n            if(initialX < 0 || initialX >= n)\n                return ans;\n            if(initialY < 0 || initialY >= n)\n                return ans;\n            ans++;\n        }\n        return ans;\n    }\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        int[] res = new int[s.length()];\n        \n        for(int i=0;i<s.length();i++) {\n            String str = s.substring(i);\n            \n            res[i] = execute(n,startPos,str);\n        }\n        return res;\n    }\n}\n```
['Java']