Detailed easy Solution with comments
\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        //Make array of length equal to string length\n        int 
```\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        //Make array of length equal to string length\n        int ans[]=new int[s.length()];\n        \n        //Now use two for loops \n        for(int i=0;i<s.length();i++){\n            //countmoves will keep on counting the valid moves from i to s.length \n            int countMoves=0;\n            int yIndex=startPos[0];\n            int xIndex=startPos[1];\n            for(int j=i;j<s.length();j++){\n                \n                if(s.charAt(j)==\'R\'){\n                    xIndex++;\n                }\n                if(s.charAt(j)==\'L\'){\n                       xIndex--; \n                }\n               if(s.charAt(j)==\'U\'){\n                        yIndex--;\n                }\n                if(s.charAt(j)==\'D\'){\n                    yIndex++;\n                }\n                if(xIndex<0 || xIndex>=n || yIndex<0 || yIndex>=n){\n                    break;\n                }\n                else{\n                    countMoves++;\n                }\n            }\n            \n            ans[i]=countMoves;\n            \n            \n        }\n        return ans;\n        \n    }\n}\n```
['Java']