[C++] Iterative BFS solution | Easy to Understand
\nclass Solution {\npublic:\n    bool isValid(int row,int col,int n){\n        return (row >= 0 && row < n && col >= 0 && col < n);\n    }\n    vector<int> exec
```\nclass Solution {\npublic:\n    bool isValid(int row,int col,int n){\n        return (row >= 0 && row < n && col >= 0 && col < n);\n    }\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int len = s.length();\n        vector<int> ans;\n        int row = startPos[0];\n        int col = startPos[1];\n        int currRow = row;\n        int currCol = col;\n        \n        for(int i=0; i<len; i++){\n            currRow = row;\n            currCol = col;\n            int currAns = 0;\n            for(int j=i; j<len; j++){\n                \n                if(s[j] == \'R\') currCol++;\n                else if(s[j] == \'L\') currCol--;\n                else if(s[j] == \'U\') currRow--;\n                else currRow++;\n                \n                if(isValid(currRow,currCol,n))\n                    currAns++;\n                else\n                    break;\n            }\n            ans.push_back(currAns);\n        }\n        return ans;\n    }\n};\n```
['Breadth-First Search', 'C', 'C++']