java| simple loop
```\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        int out [] = new int [s.length()];\n        \n        fo
```\nclass Solution {\n    public int[] executeInstructions(int n, int[] startPos, String s) {\n        int out [] = new int [s.length()];\n        \n        for(int i=0;i<s.length();i++){\n            int c = 0;\n            int x = startPos[0];\n            int y = startPos[1];\n            for(int j=i;j<s.length();j++){\n                if(s.charAt(j) == \'R\'){\n                    if(y < n-1){\n                        c++;\n                        y++;\n                    }else {\n                        break;\n                    }\n                }else if(s.charAt(j) == \'L\'){\n                    if(y > 0){\n                        c++;\n                        y--;\n                    }else {\n                        break;\n                    }\n                }else if(s.charAt(j) == \'U\'){\n                    if(x > 0){\n                        c++;\n                        x--;\n                    }else {\n                        break;\n                    }\n                }else {\n                    if(x < n-1){\n                        c++;\n                        x++;\n                    }else {\n                        break;\n                    }\n                }                    \n            }\n            out[i] = c;\n        }\n        return out;\n    }\n}
[]