Bitmask DP || All Bitmask DP Lists || Detail Explained || 100% common topics in today's contest!
Bitmask DP Lists: https://leetcode.com/problem-list/mtxjny0h/\n\n# Code\ncpp []\n\n#define ll long long\n#define rep0(i,n) for(ll i = 0; i < n; i++)\n#define me
Bitmask DP Lists: https://leetcode.com/problem-list/mtxjny0h/\n\n# Code\n```cpp []\n\n#define ll long long\n#define rep0(i,n) for(ll i = 0; i < n; i++)\n#define memo(a) memset(a, -1, sizeof(a));\n#define len(x) ((ll)x.size()) \n#define pb push_back\n\nclass Solution {\npublic:\n    vector<vector<int>> nums;\n    int dp[101][1025];\n\n    int rec(int num, int bitmask) {\n        if(num == 0) return 0;\n        if(dp[num][bitmask] != -1) return dp[num][bitmask];\n\n        //not take this number\n        int ans = rec(num-1, bitmask);    \n        \n        //take this number, we should get the number and which row it exists, number can be in multiple row    \n        for(auto row : nums[num]) { //which row this number belongs?\n            int bit = 1 << row; \n            if((bitmask & bit) == 0) { // if we never take item from this row, take from this row\n                ans = max(ans, rec(num-1, bitmask | bit) + num); // add number with ans\n            }\n        }\n\n        return dp[num][bitmask] = ans;\n    }\n\n    int maxScore(vector<vector<int>>& grid) {\n        int rows = len(grid), cols = len(grid[0]);\n        nums.resize(101);\n\n        memo(dp);\n\n        //keep track which row a number belongs to, a number can be in multiple row\n        rep0(i, rows) {\n            rep0(j, cols) {\n                nums[grid[i][j]].pb(i);\n            }\n        }\n\n        //number can be at max 100, so we will check all number and it\'s row\n        ll ans = rec(100, 0);\n        return ans;\n    }\n};\n\n```\n\nA Gem for Beginners! I discussed Importance of DP here in contests and coding Interviews to Improve Ratings.\n<iframe width="560" height="315" src="https://www.youtube.com/embed/XAd0r5MvQiA" title="" frameBorder="0"   allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"  allowFullScreen><br>Powered by <a href="https://youtubeembedcode.com">html embed youtube video</a> and <a href="https://casinomga.se/">nya mga casino</a></iframe>\n\n100% questions is common in today\'s contest. I discussed few topics that would cover 80% coding contest and interviews problems. today 2nd one was priority queue, 3rd one was bitmask dp and 4th one was dp. All topics I discussed in my video. Feel free to watch those topics I discussed. It\'s a gem fro beginners.\n\n![0a95fea4-64f4-4502-82aa-41db6d77c05c_1676054939.8270252.jpeg](https://assets.leetcode.com/users/images/5c3c12f1-f521-4c7f-afec-337c965c1628_1725167389.0772295.jpeg)\n
['Dynamic Programming', 'Memoization', 'Bitmask', 'C++']