C++ | Easy to understand |
```\nvoid findInstructionsNo(int n,int row,int col,string &s,vector& res,int count,int index)\n    {\n        if(row>=n || col>=n || row<0 || col<0 )\n        {
```\nvoid findInstructionsNo(int n,int row,int col,string &s,vector<int>& res,int count,int index)\n    {\n        if(row>=n || col>=n || row<0 || col<0 )\n        {\n            count--;\n            res.push_back(count);\n            return;\n        }\n        \n        if(index>=s.length())\n        {\n            res.push_back(count);\n            return;\n        }\n        \n        \n        int c=s[index];\n        if(c==\'U\')\n            findInstructionsNo(n,row-1,col,s,res,count+1,index+1);\n        if(c==\'D\')\n            findInstructionsNo(n,row+1,col,s,res,count+1,index+1);\n        if(c==\'L\')\n            findInstructionsNo(n,row,col-1,s,res,count+1,index+1);\n        if(c==\'R\')\n            findInstructionsNo(n,row,col+1,s,res,count+1,index+1);\n    }\n    \n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) \n    {\n        vector<int> res;\n        while(s.length()>0)\n        {\n            findInstructionsNo(n,startPos[0],startPos[1],s,res,0,0);\n            s=s.substr(1);\n        }\n            return res;\n    }
[]