Simple Solution
Code

# Code
```javascript []
/**
 * @param {number} n
 * @param {number[]} startPos
 * @param {string} s
 * @return {number[]}
 */
var executeInstructions = function(n, startPos, s) {
    let res = [];

    for (let j = 0; j < s.length; j++) {
        let count = 0;
        let x = startPos[1]; 
        let y = startPos[0]; 

        for (let i = j; i < s.length; i++) {
            if (s[i] == 'L') {
                if (x <= 0) break;
                x--; 
            }
            else if (s[i] == 'R') {
                if (x >= n - 1) break; 
                x++; 
            }
            else if (s[i] == 'U') {
                if (y <= 0) break; 
                y--; 
            }
            else if (s[i] == 'D') {
                if (y >= n - 1) break; 
                y++; 
            }
            count++;
        }
        res.push(count);
    }

    return res;
};

```
['JavaScript']