C++ basic easy understanding brute force approach
\nclass Solution {\npublic:\n    bool check(int i, int j,int n){\n         return (i>=0 && j>=0 && i <n && j<n);\n    }  \n    vector<int> executeInstructions(i
```\nclass Solution {\npublic:\n    bool check(int i, int j,int n){\n         return (i>=0 && j>=0 && i <n && j<n);\n    }  \n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int x = startPos[0];\n        int y = startPos[1];\n        vector<int> ans;\n        for(int i = 0;i<s.size();i++){\n           int x = startPos[0];\n           \n           int y = startPos[1];\n           int count = 0;\n           for(int j=i;j<s.size();j++){\n      \n               if(s[j] == \'L\'){\n                   if(check(x,y-1,n)){\n                       x = x;\n                       y = y-1;\n                       count++;\n                       \n                   }\n                   else {\n                       break;\n                       count = 0;\n                   }\n               }\n               if(s[j] == \'U\'){\n                   \n                   if(check(x-1,y,n)){\n                       x = x-1;\n                       y = y;\n                       count++;\n                   }\n                   else {\n                       break;\n                       count = 0;\n                   }\n               }\n               if(s[j] == \'R\'){\n                   if(check(x,y+1,n)){\n                       x = x;\n                       y = y+1;\n                       count++;\n                   }\n                   else {\n                       break;\n                       count = 0;\n                   }\n               }\n               if(s[j] == \'D\'){\n                   if(check(x+1,y,n)){\n                       x = x+1;\n                       y = y;\n                       count++;\n                   }\n                   else {\n                       break;\n                       count = 0;\n                   }\n               }\n               \n               \n           }\n            ans.push_back(count);\n        } return ans;\n        \n    }\n};\n```
['C']