C#
Intuition\nsimulate\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nsimulate and brute force\n Describe your approach to solving th
# Intuition\nsimulate\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nsimulate and brute force\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:?\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution\n        {\n            public int[] ExecuteInstructions(int n, int[] startPos, string s)\n            {\n                int[] result = new int[s.Length];\n\n                for(int i = 0;i<s.Length ;i++)\n                {\n                    int row = startPos[0];\n                    int col = startPos[1];\n                    int count = 0;\n\n                    foreach(char c in s.Substring(i, s.Length-i))\n                    {\n                        if (c == \'R\')\n                            col++;\n                        else if (c == \'L\')\n                            col--;\n                        else if (c == \'U\')\n                            row--;                        \n                        else if (c == \'D\')\n                            row++;                        \n\n                        if (row >= n || row < 0 || col >= n || col < 0)\n                            break;\n                        count++;                        \n                    }\n                    result[i] = count;\n                }\n                return result;\n            }\n            \n        }\n```
['C#']