Easy to understand JS Brute Force solution
Starting from every index, simulate the Robot\'s movements. At the end of each move, check if Robot is out of grid. Break out to start new iteration if out of g
Starting from every index, simulate the Robot\'s movements. At the end of each move, check if Robot is out of grid. Break out to start new iteration if out of grid else increment the `res` for `ith` index and continue the process\n```\nvar executeInstructions = function(n, startPos, s) {\n    let res = Array(s.length).fill(0)\n    for(let i = 0; i < s.length; i++){\n        let [currX, currY] = startPos;\n        for(let j = i; j < s.length; j++){\n            switch(s[j]){\n                case \'L\':{\n                    currY -= 1;\n                }\n                    break;\n                case \'R\':{\n                    currY += 1;\n                }\n                    break;\n                case \'U\':{\n                    currX -= 1;\n                }\n                    break;\n                case \'D\':{\n                    currX += 1;\n                }\n                    break;\n            }\n            if(currX < 0 || currY < 0 || currX >= n || currY >= n)\n                break;\n            res[i] += 1;\n        }\n    }\n    return res;\n};\n```
['Simulation', 'JavaScript']