C++ DFS dp memo
Could not solve this during the contest :(\n\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    vector<vector<int>> nums;\n    int maxScore(vector<vec
Could not solve this during the contest :(\n```\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    vector<vector<int>> nums;\n    int maxScore(vector<vector<int>>& g) {\n        nums.resize(101);\n        for (int i = 0; i < g.size(); ++i)\n            for (int y = 0; y < g[0].size(); ++y)\n                nums[g[i][y]].push_back(i);\n        dp = vector<vector<int>>(101, vector<int>(1025, -1));\n        return dfs(0, 0);\n    }\n\n    int dfs(int i, int bitMask){\n        if (i == nums.size()) return 0;\n        if (dp[i][bitMask] != -1)\n            return dp[i][bitMask];\n        // do not take\n        int ans = dfs(i + 1, bitMask);\n        // iterate row options\n        for (int x = 0; x < nums[i].size(); ++x){\n            int bit = 1 << nums[i][x];\n            if ((bitMask & bit) == 0){\n                int nextBit = bitMask | bit;\n                ans = max(ans, dfs(i + 1, nextBit) + i);\n            }\n        }\n        return dp[i][bitMask] = ans;\n    }\n};\n```
['C++']