DP with bitmasking || Explained
```\n/\n\nusing bitmask to keep track of pawn already captured\n\ntrying all possible cases\n\n\ndp[idx][mask][turn] = if its alice turn or not, min/max steps t
```\n/*\n\nusing bitmask to keep track of pawn already captured\n\ntrying all possible cases\n\n\ndp[idx][mask][turn] = if its alice turn or not, min/max steps taken by knight at pos[idx] to capture the uncaptured pawn\n*/\n\nint N = 50;  \n\nint dx[8] = {2, 2, -2, -2, 1, 1, -1, -1};\n\nint dy[8] = {1, -1, 1, -1, 2, -2, 2, -2};\n\nint dp[16][1<<16][2]; \n\nint n;\n\n\nunordered_map<int, unordered_map<int, unordered_map<int,int>>>mp;\n\nclass Solution {\npublic:\n    int maxMoves(int kx, int ky, vector<vector<int>>& pos) {\n        \n        // precomputation : from ecah pawn cell, finding min steps to move to rest of the cells\n        \n        // mp[kx][ky][idx]= min steps knoight takes to move from [idx] to [kx,ky]\n                \n                for(int idx=0;idx<pos.size();idx++){\n                    findSteps(idx, pos);\n            }\n        \n        n = pos.size();\n        memset(dp, -1, sizeof(dp)); \n        int mask=0;\n        int ans=INT_MIN;\n        for(int i=0;i<pos.size();i++){\n            ans=max(ans,mp[kx][ky][i]+ find(i,mask|(1<<i),0,pos));\n        }\n        return ans; \n    }\n\n    int find(int p, int mask, int alice, vector<vector<int>>& pos) {\n        \n        if (mask == (1 << n) - 1) \n            return 0;\n\n        if (dp[p][mask][alice] != -1)\n            return dp[p][mask][alice];\n\n        int result;\n        if (alice)  \n            result = INT_MIN;\n        else  \n            result = INT_MAX;\n\n        for (int i = 0; i < pos.size(); i++) {\n            if (mask & (1 << i)) \n                continue;\n            \n            int kx=pos[p][0];\n            \n            int ky=pos[p][1];\n\n            int steps = mp[kx][ky][i];\n            if (alice) {\n                result = max(result, steps + find(i, mask | (1 << i), 0, pos));\n            } else {\n                result = min(result, steps + find(i, mask | (1 << i), 1, pos));\n            }\n        }\n\n        return dp[p][mask][alice] = result;\n    }\n\n   \n\n    \n    // O(50*50)\n    \n    \n    void findSteps(int idx, vector<vector<int>>&pos) {\n        \n        int kx=pos[idx][0];\n        \n        int ky=pos[idx][1];\n        \n        vector<vector<int>> dist(N, vector<int>(N, -1));\n        \n\n        queue<pair<int, int>> q;\n\n        q.push({kx, ky});\n        dist[kx][ky] = 0;\n\n        while (!q.empty()) {\n            auto [x, y] = q.front();\n            q.pop();\n\n            // if (x == ex && y == ey) {\n            //     return dist[x][y];\n            // }\n\n            for (int i = 0; i < 8; ++i) {\n                int nx = x + dx[i];\n                int ny = y + dy[i];\n                \n                if (isValid(nx, ny) && dist[nx][ny] == -1) {\n                    dist[nx][ny] = dist[x][y] + 1;\n                    mp[nx][ny][idx]=dist[nx][ny];\n                    q.push({nx, ny});\n                }\n            }\n        }\n  \n    }\n    \n    \n     bool isValid(int x, int y) {\n        return x >= 0 && x < N && y >= 0 && y < N;\n    }\n    \n    \n};\n
['Breadth-First Search', 'C', 'Bitmask', 'C++']