java, simulation
\nCode:\n\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        \n        int[] ans = new int[s.length()];\n        for(int i=0;i<s.
\n**Code:**\n\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        \n        int[] ans = new int[s.length()];\n        for(int i=0;i<s.length();i++){\n            int count = 0;\n            int[] curr = {startPos[0], startPos[1]};\n            \n            for(int j=i;j<s.length();j++){\n                switch(s.charAt(j)){\n                    case \'L\':\n                        curr[1] = curr[1]-1; break;\n                    case \'R\':\n                        curr[1] = curr[1]+1; break;\n                    case \'U\':\n                        curr[0] = curr[0]-1; break;\n                    case \'D\':\n                        curr[0] = curr[0]+1; break;\n                }\n                if(curr[0]<0||curr[0]==n||curr[1]<0||curr[1]==n)\n                    break;\n                count++;\n            }\n            ans[i] = count;\n        }\n        return ans;\n    }
['Java']