Brute Force Recursion JAVA solution
Changes MADE:\nstartPos -> strPos\n\n\npublic int[] executeInstructions(int n, int[] strPos, String s)\n{\n\n\t\tint a[] =new int[s.length()];\n        for (int
Changes MADE:\nstartPos -> strPos\n\n\npublic int[] executeInstructions(int n, int[] strPos, String s)\n{\n\n\t\tint a[] =new int[s.length()];\n        for (int i = 0; i < s.length(); i++) {\n            int counter = 0;\n            a[i] = find(strPos[0],strPos[1],n,s.substring(i),counter);\n        }\n        return a;\n    }\n\n    public static int find(int r, int c,int n,String s,int counter) {\n        if (counter < s.length())\n        {\n            if (s.charAt(counter) == \'L\' && c - 1 < n && c - 1 >= 0 && r < n && r >= 0) {\n                return find(r, c - 1, n, s, counter + 1);\n            }\n        if (s.charAt(counter) == \'R\' && c + 1 < n && c + 1 >= 0 && r < n && r >= 0) {\n            return find(r, c + 1, n, s, counter + 1);\n        }\n        if (s.charAt(counter) == \'U\' && r - 1 < n && r - 1 >= 0 && c < n && c >= 0) {\n            return find(r - 1, c, n, s, counter + 1);\n        }\n        if (s.charAt(counter) == \'D\' && r + 1 < n && r + 1 >= 0 && c < n && c >= 0) {\n            return find(r + 1, c, n, s, counter + 1);\n        }\n    }\n        return counter;\n}
['Recursion', 'Java']