✅💯🎊Simple C++ Code🎊🎊 || ✔Easy to understand🎯 || Easy Logic || Beginner friendly || Beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \nthere are total 10 rows, it means we can take a bit of number 2 ke power 10 = number 10
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nthere are total 10 rows, it means we can take a bit of number 2 ke power 10 = number 1024;\nmene vector v banaya hu jo har element ko store kar rha hai woh row me hai ,\nthen humne number ka limit diya tha number maximum 100 tak ja sakta hai\nhum dekhnge kya uss row se number liye hai ki nhi (musk & (1<<it)) == 0, auto it karke dekh lenge\nagar nhi liye hai toh le lenge, phir num ko -1 kar denge base cases num == 0 hoga.\n\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```cpp []\nclass Solution {\npublic:\n        vector<int>v[101];\n        int dp[101][1025];\n    int solve(int num, int musk){\n        if(num == 0)return 0;\n        if(dp[num][musk] != -1)return dp[num][musk];\n        int ans =0;\n            int take =0;\n            int not_take = solve(num-1,musk);\n        for(auto it : v[num]){\n            if((musk & (1<<it)) == 0){\n            // cout<<(musk & (1<<it))<<" z "<<num<<\'\\n\';\n               take = max(take, num + solve(num - 1, (musk | (1 << it))));\n            }\n            // if(num == 19){\n            // cout<<ans<<" x "<<take<<\'\\n\';\n            // }\n        }\n            ans =max({ans,take,not_take});\n        return  dp[num][musk] = ans;\n    }\n    \n    int maxScore(vector<vector<int>>& g){\n        // set<int>st;\n        int n= g.size();\n        int m = g[0].size();\n        memset(dp,-1,sizeof(dp));\n        for(int i =0; i< n; i++){\n            for(int j =0; j< m; j++){\n                v[g[i][j]].push_back(i);\n            }\n        }\n        return solve(100,0);\n    }\n};\n```
['Dynamic Programming', 'Bitmask', 'C++']