Easiest detailed solution || 100% faster||Brute-force
```\nclass Solution {\n    \n    bool left(int i,int j)\n    {\n        j--;\n        if(j<0)\n            return false;\n        return true;\n    }\n    bool 
```\nclass Solution {\n    \n    bool left(int i,int j)\n    {\n        j--;\n        if(j<0)\n            return false;\n        return true;\n    }\n    bool right(int i,int j,int &n)\n    {\n        j++;\n        if(j==n)\n            return false;\n        return true;\n    }\n    bool up(int i,int j)\n    {\n        i--;\n        if(i<0)\n            return false;\n        return true;\n    }\n    bool down(int i,int j,int n)\n    {\n        i++;\n        if(i==n)\n            return false;\n        return true;\n    }\n    \n    vector<int>check(int n,string s,int m,int k)\n    {\n        vector<int>vec(s.size());\n     for(int i=0;i<s.size();i++)\n     {\n         int a=m;\n         int b=k;\n         int count=0;\n         for(int j=i;j<s.size();j++)\n         {\n             if(s[j]==\'R\')\n             {\n                 if(right(a,b,n))\n                 {\n                     count++;\n                     b++;\n                 }\n                 else break;\n             }\n              if(s[j]==\'L\')\n             {\n                 if(left(a,b))\n                 {\n                     count++;\n                     b--;\n                 }\n               else break;\n\n             }\n              if(s[j]==\'U\')\n             {\n                 if(up(a,b))\n                 {\n                     count++;\n                     a--;\n                 }\n              else break;\n             }\n              if(s[j]==\'D\')\n             {\n                 if(down(a,b,n))\n                 {\n                     count++;\n                     a++;\n                 }\n                else break;\n             }\n         }\n         vec[i]=count;\n     }\n        return vec;\n    }\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int i=startPos[0];\n        int j=startPos[1];\n        \n        vector<int>ans=check(n,s,i,j);\n        \n        return ans;\n        \n    }\n};
['C']