Python Solution | Easy implementation | Easy to understand | Fast
class Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        result = []\n        for i in range (0,len(s)):\n
```class Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        result = []\n        for i in range (0,len(s)):\n             ch= s [i:]\n             actualPos = copy.copy(startPos)\n             numberSteps=0\n             for step in ch :\n                    if step == \'U\':\n                        actualPos[0]-=1\n                    elif step == \'D\':\n                        actualPos[0] +=1\n                    elif step == \'R\':\n                        actualPos[1]+=1\n                    elif step ==\'L\':\n                        actualPos[1]-=1\n                        \n                    ## Condition of leaving the grid \n                    if actualPos[0]<0 or actualPos[1]<0 or actualPos[0]>n-1 or actualPos[1]> n-1 :\n                        break\n                    else: \n                        numberSteps +=1\n                        \n                   \n             result.append (numberSteps)\n                    \n        return result ```
['Python']