Beginner friendly Java Solution
Time Complexity : O(n*n)\njava []\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        int arr[] = new int[s.leng
**Time Complexity : O(n*n)**\n```java []\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        int arr[] = new int[s.length()];\n        for(int i=0; i<s.length(); i++){\n            int xid = startPos[1], yid = startPos[0], count = 0;\n            for(int j=i; j<s.length(); j++){\n                if(s.charAt(j) == \'R\')  xid++;\n                if(s.charAt(j) == \'L\')  xid--;\n                if(s.charAt(j) == \'D\')  yid++;\n                if(s.charAt(j) == \'U\')  yid--;\n                if(xid < 0 || yid < 0 || xid >= n || yid >= n)  break;\n                else count++;\n            }\n            arr[i] = count;\n        }\n        return arr;\n    }\n}\n```
['Java']