✅Brute Forces Approach || very easy to understand 👍|| 100%🔥
Intuition\nIterate through the each s[i] and check weather it fulfil the condition or not;\n\n# Approach\nBruteforce approach\n\n# Complexity\n- Time complexity
# Intuition\nIterate through the each s[i] and check weather it fulfil the condition or not;\n\n# Approach\nBruteforce approach\n\n# Complexity\n- Time complexity:\nO(s.length*2)\n\n- Space complexity: O(s.lenght);\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n\n        vector<int>ans;\n        for(int i=0;i<s.size();i++)\n        {\n            int count = 0;\n            int row = startPos[0];\n            int col = startPos[1];\n            for(int j=i;j<s.size();j++)\n            {\n                if(s[j]==\'L\') col--;\n                if(s[j]==\'R\') col++;\n                if(s[j]==\'D\') row++;\n                if(s[j]==\'U\') row--;\n\n                if(col<0 || row<0 || col>=n || row>=n)\n                    break;\n                else\n                    count++;\n            }\n            ans.push_back(count);\n\n        }\n        return ans;\n    }\n};\n```
['C++']