Java || userfriendly || beginner friendly
\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        \n        int m=s.length();\n        int ans[]=new int[m];\
```\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        \n        int m=s.length();\n        int ans[]=new int[m];\n        \n        \n        for(int i=0;i<m;i++)\n        {\n            int x=startPos[0];\n            int y=startPos[1];\n            int count=0;\n            for(int j=i;j<m;j++)\n            {\n                if(s.charAt(j)==\'L\')\n                    y--;\n                else if(s.charAt(j)==\'R\')\n                    y++;\n                else if(s.charAt(j)==\'U\')\n                    x--;\n                else \n                    x++;\n                \n                if((x>=0 && x<n) && (y>=0 && y<n))\n                    count++;\n                else \n                    break;\n            }\n            ans[i]=count;\n        }\n        \n        return ans;\n    }\n}\n```
[]