Simple Clean Solution
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: O(2^n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(2500 * (n+1))\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<vector<int>> dir={{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}};\n    int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n        int n=positions.size();\n        vector<vector<vector<int>>> leastMoves(n+1,vector<vector<int>>(50,vector<int>(50,INT_MAX)));\n        vector<vector<int>> visited(50,vector<int>(50,0));\n        //bfs from knight pos to pawns\n        bfs(kx,ky,visited,leastMoves,0);\n        for(int i=0;i<n;i++){\n            vector<vector<int>> visited(50,vector<int>(50,0));\n            bfs(positions[i][0],positions[i][1],visited,leastMoves,i+1);\n        }\n        unordered_map<int,vector<int>> cache;\n        return dp(0,positions,0,0,leastMoves,cache);\n    }\n\n    \n    int dp(int index,vector<vector<int>>& positions,int isBob,long long bitMask,vector<vector<vector<int>>>& leastMoves,unordered_map<int,vector<int>>& cache){\n        if(bitMask==((1<<positions.size())-1)){\n            return 0;\n        }\n\n        if(cache.find(bitMask)==cache.end()){\n            cache[bitMask].resize(positions.size()+1,-1);\n        }\n\n        if(cache[bitMask][index]!=-1){\n            return cache[bitMask][index];\n        }\n\n        int ans;\n        if(!isBob){\n            ans=INT_MIN;\n            for(int i=0;i<positions.size();i++){\n                if(bitMask & (1 << i)){\n                    continue;\n                }\n                ans=max(ans,leastMoves[index][positions[i][0]][positions[i][1]]+dp(i+1,positions,!isBob,bitMask|(1<<i),leastMoves,cache));\n            }\n        } else {\n            ans=INT_MAX;\n            for(int i=0;i<positions.size();i++){\n                if(bitMask & (1 << i)){\n                    continue;\n                }\n                ans=min(ans,leastMoves[index][positions[i][0]][positions[i][1]]+dp(i+1,positions,!isBob,bitMask|(1<<i),leastMoves,cache));\n            }\n        }\n        return cache[bitMask][index]=ans;\n    }\n\n    void bfs(int x,int y,vector<vector<int>>& visited,vector<vector<vector<int>>>& leastMoves,int index){\n        queue<pair<int,int>> q;\n        q.push({x,y});\n        leastMoves[index][x][y]=0;\n        int level=1;\n        visited[x][y]=1;\n        while(!q.empty()){\n            int size=q.size();\n            while(size){\n                int posX=q.front().first;\n                int posY=q.front().second;\n                q.pop();\n                size--;\n                for(int i=0;i<8;i++){\n                    int newX= posX+dir[i][0];\n                    int newY= posY+dir[i][1];\n                    if(newX>=0 && newX<50 && newY>=0 && newY<50 && visited[newX][newY]==0){\n                        visited[newX][newY]=1;\n                        leastMoves[index][newX][newY]=level;\n                        q.push({newX,newY});\n                    }\n                }\n            }\n            level++;\n        }\n        return;\n    }\n\n};\n```
['Dynamic Programming', 'Bit Manipulation', 'Breadth-First Search', 'Memoization', 'C++']