Simple and Easy JAVA Solution using BFS to find the minimum distance and DFS , Memoization
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\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:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int maxMoves(int kx, int ky, int[][] positions) {\n        // Using bfs to find the minimum distance to travel from\n        // One pawn location to the other\n\n        //Using DFS to find the maximum in all possible choices\n        int n = positions.length;\n        int distances[][] = new int[n][n];\n        for(int i=0;i<n;i++)\n            for(int j=0;j<n;j++){\n                distances[i][j] = bfs(positions[i][0],positions[i][1],positions[j][0],positions[j][1]);\n            }\n\n        int initialDist[] = new int[n];\n        for(int i=0;i<n;i++)\n            initialDist[i] = bfs(kx,ky,positions[i][0],positions[i][1]);\n\n        return dfs(initialDist, distances, (1 << positions.length) - 1, -1, true, new HashMap<>());\n    }\n\n     private int dfs(int[] initialDist, int[][] distances, int mask, int last, boolean isAlice, Map<Long, Integer> memo) {\n        if (mask == 0) return 0;\n        \n        long key = ((long) mask << 33) | ((long) last << 1) | (isAlice ? 1 : 0);\n        if (memo.containsKey(key)) return memo.get(key);\n        \n        int res = isAlice ? Integer.MIN_VALUE : Integer.MAX_VALUE;\n        for (int i = 0; i < initialDist.length; i++) {\n            if ((mask & (1 << i)) != 0) {\n                int newMask = mask ^ (1 << i);\n                int dist = (last == -1) ? initialDist[i] : distances[last][i];\n                int subRes = dfs(initialDist, distances, newMask, i, !isAlice, memo);\n                if (isAlice) {\n                    res = Math.max(res, subRes + dist);\n                } else {\n                    res = Math.min(res, subRes + dist);\n                }\n            }\n        }\n        \n        memo.put(key, res);\n        return res;\n    }\n\n    private int bfs(int sR,int sC,int eR,int eC){\n        Queue<int []> queue = new LinkedList<>();\n        boolean visited[][] = new boolean[50][50];\n        visited[sR][sC] = true;\n        queue.offer(new int[]{sR,sC,0});\n\n        while(!queue.isEmpty()){\n            int arr[] = queue.poll();\n            int r = arr[0] , c = arr[1] , moves = arr[2];\n\n            if(r == eR && c == eC)\n                return moves;\n            \n            int nxtR[] = new int[]{2,1,-1,-2,2,1,-2,-1};\n            int nxtC[] = new int[]{1,2,2,1,-1,-2,-1,-2};\n            for(int i=0;i<8;i++){\n                int nR = r + nxtR[i];\n                int nC = c + nxtC[i];\n\n                if(inLimit(nR,nC) && !visited[nR][nC]){\n                    queue.offer(new int[]{nR,nC,moves+1});\n                    visited[nR][nC] = true;\n                }\n            }\n        }\n\n        return -1;\n    }\n\n    private boolean inLimit(int r,int c){\n        if(r >= 50 || r < 0 || c >= 50 || c < 0)\n            return false;\n        return true;\n    }\n}\n```
['Java']