C++ || SIMULATION || EASY TO UNDERSTAND
```\nclass Solution {\npublic:\n    vector executeInstructions(int n, vector& startPos, string s) {\n         vector ans;\n        \n           for(int i=0; i<s
```\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n         vector<int> ans;\n        \n           for(int i=0; i<s.size(); i++){\n               int sr = startPos[0];\n               int sc = startPos[1];\n               int cnt = 0;\n               bool flag = false;\n               for(int j = i; j<s.size(); j++){\n                                   \n                   char ch = s[j];\n                   if(ch == \'L\'){\n                          if(sc > 0 ) {cnt++; sc-=1;}\n                          else {flag = true ;break;}\n                   }\n                   if(ch == \'R\'){\n                          if(sc < n-1) {cnt++; sc+=1;}\n                          else {flag = true ;break;}\n                   }\n                   if(ch == \'U\'){\n                          if(sr > 0 ) {cnt++; sr-=1;}\n                          else {flag = true ;break;}\n                   }\n                   if(ch == \'D\'){\n                          if(sr < n-1 ) {cnt++; sr+=1;}\n                          else {flag = true ;break;}\n                   }\n                   \n               }\n               if(!flag) ans.push_back(s.size() - i);\n                   else ans.push_back(cnt);\n                  \n           }\n              return ans;\n        \n    }\n};
['C', 'Simulation']