easy solution!!! || beats 83.96%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        vector<int> ans;\n        bool inside=true;\n        int row=startPos[0];\n        int col=startPos[1];\n        int step=0;\n        for(int i=0;i<s.length();i++){\n            for(int j=i;j<s.length() && inside==true;j++){\n                switch(s[j]){\n                    case \'L\':\n                        col--;\n                        if(col<0 || col>n-1){\n                            col++;\n                            ans.push_back(step);\n                            inside=false;\n                        }\n                        else\n                            step++;\n                    break;\n                    case \'R\':\n                        col++;\n                        if(col<0 || col>(n-1)){\n                            col--;\n                            ans.push_back(step);\n                            inside=false;\n                        }\n                        else\n                            step++;\n                    break;\n                    case \'U\':\n                        row--;\n                        if(row<0 || row>n-1){\n                            row++;\n                            ans.push_back(step);\n                            inside=false;\n                        }\n                        else\n                            step++;\n                    break;\n                    case \'D\':\n                        row++;\n                        if(row<0 || row>n-1){\n                            row--;\n                            ans.push_back(step);\n                            inside=false;\n                        }\n                        else\n                            step++;\n                    break;\n                }\n            }\n            if(inside==true)\n                ans.push_back(step);\n            inside=true;\n            step=0;\n            row=startPos[0];\n            col=startPos[1];\n        }\n        return ans;\n    }\n};\n```
['C++']