question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
smallest-index-with-equal-value | Java Solution faster than 94% | java-solution-faster-than-94-by-vishwaje-dko2 | \nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i = 0;i<nums.length;i++)\n if(i%10==nums[i])\n return | vishwajeet_rauniyar | NORMAL | 2022-05-27T13:31:37.584636+00:00 | 2022-05-27T13:31:37.584668+00:00 | 37 | false | ```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i = 0;i<nums.length;i++)\n if(i%10==nums[i])\n return i;\n return -1;\n }\n}\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | Easy python solution | easy-python-solution-by-rupeshmohanty-e54w | \nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n res = []\n \n for i in range(len(nums)):\n if i % 10 = | rupeshmohanty | NORMAL | 2022-05-10T15:09:04.434948+00:00 | 2022-05-10T15:09:04.434977+00:00 | 108 | false | ```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n res = []\n \n for i in range(len(nums)):\n if i % 10 == nums[i]:\n res.append(i)\n \n if len(res) > 0:\n return min(res)\n else:\n return -1\n``` | 1 | 0 | ['Python'] | 0 |
smallest-index-with-equal-value | C++ beginner friendly solution | c-beginner-friendly-solution-by-pratium-072t | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int n=nums.size();\n for(int i=0;i<n;i++){\n if(i%10==nums[i] | pratium | NORMAL | 2022-05-02T09:21:32.889686+00:00 | 2022-05-02T09:21:32.889737+00:00 | 28 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int n=nums.size();\n for(int i=0;i<n;i++){\n if(i%10==nums[i]){\n return i;\n break;}\n }\n return -1;\n }\n};\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | Java Solution - O(N) | java-solution-on-by-solved-fxbj | \nclass Solution {\n public int smallestEqual(int[] nums) {\n for (int i = 0; i < nums.length; i++) {\n if (i % 10 == nums[i]) {\n | solved | NORMAL | 2022-03-21T16:41:03.903853+00:00 | 2022-03-21T16:41:03.903899+00:00 | 28 | false | ```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for (int i = 0; i < nums.length; i++) {\n if (i % 10 == nums[i]) {\n return i;\n }\n }\n return -1;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | Without Modular operator | follow-up question | without-modular-operator-follow-up-quest-hm74 | With modulus it\'s easy, here is without modulus\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n int index = 0;\n for (int i = 0 | nishantk3101 | NORMAL | 2022-03-12T22:13:56.080135+00:00 | 2022-03-12T22:13:56.080163+00:00 | 56 | false | **With modulus it\'s easy, here is without modulus**\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int index = 0;\n for (int i = 0 ; i < nums.length; i++) {\n if (index == nums[i]) {\n return i;\n }\n if (++index== 10) {\n ... | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | C++ | Easy Solution | O(n) time complexity | Clean Code | c-easy-solution-on-time-complexity-clean-foa7 | Please Upvote if you found this useful.\n\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) \n {\n for(int i=0; i<nums.size(); i+ | saketgautam | NORMAL | 2022-02-19T22:57:38.746586+00:00 | 2022-02-19T22:57:38.746613+00:00 | 61 | false | **Please Upvote if you found this useful.**\n\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) \n {\n for(int i=0; i<nums.size(); i++)\n {\n if(i % 10== nums[i])\n {\n return i;\n }\n }\n return -1;\n }\n};\n``` | 1 | 0 | ['C', 'C++'] | 0 |
smallest-index-with-equal-value | Java Solution | Memory Usage is less than 73.35% of online submissions | | java-solution-memory-usage-is-less-than-d7gq2 | class Solution {\n public int smallestEqual(int[] nums) {\n int smallIndex = -1;\n for (int i=nums.length-1; i>=0; i--){\n int help | m1502 | NORMAL | 2022-01-14T12:23:29.171413+00:00 | 2022-01-14T12:23:29.171454+00:00 | 78 | false | class Solution {\n public int smallestEqual(int[] nums) {\n int smallIndex = -1;\n for (int i=nums.length-1; i>=0; i--){\n int help = i % 10;\n if (help == nums[i]){\n smallIndex = i;\n }\n }\n return smallIndex;\n }\n} | 1 | 1 | ['Array', 'Java'] | 0 |
smallest-index-with-equal-value | c++ one loop | c-one-loop-by-amarp-92od | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for (int i = 0; i < nums.size(); i++) {\n if ( (i % 10) == nums[i]) | amarp | NORMAL | 2021-12-31T07:20:36.235498+00:00 | 2021-12-31T07:20:36.235537+00:00 | 43 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for (int i = 0; i < nums.size(); i++) {\n if ( (i % 10) == nums[i]) return i; \n } \n return -1; \n }\n};\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | C++ / NO MOD NO MULTI , ONLY ADD / simple solution | c-no-mod-no-multi-only-add-simple-soluti-wxwt | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int idx = 0;\n for (int i = 0 ; i < nums.size(); ++i) {\n if | pat333333 | NORMAL | 2021-12-11T07:08:36.104419+00:00 | 2021-12-11T07:09:23.772255+00:00 | 39 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int idx = 0;\n for (int i = 0 ; i < nums.size(); ++i) {\n if (idx == nums[i]) {\n return i;\n }\n if (++idx == 10) {\n idx = 0;\n }\n }\n ret... | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | [JAVA] Runtime 100% && Simple 3-Line Solution | java-runtime-100-simple-3-line-solution-3wrb8 | if you find it useful, please upvote it)\n\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++)\n if((i-nums[i])%10= | 7akhongir | NORMAL | 2021-11-26T21:07:24.752163+00:00 | 2021-11-26T21:07:49.149782+00:00 | 213 | false | if you find it useful, please upvote it)\n```\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++)\n if((i-nums[i])%10==0) return i;\n return -1;\n }\n``` | 1 | 0 | ['Java'] | 1 |
smallest-index-with-equal-value | [Python3] 1 line | python3-1-line-by-nuno-dev1-9lig | \nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n return min([i for i,el in enumerate(nums) if i%10==el],default=-1)\n | nuno-dev1 | NORMAL | 2021-11-22T12:09:20.584291+00:00 | 2021-11-22T12:09:20.584355+00:00 | 60 | false | ```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n return min([i for i,el in enumerate(nums) if i%10==el],default=-1)\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | C++ || easy solution with 1 for loop + explanation | c-easy-solution-with-1-for-loop-explanat-uqvn | class Solution {\npublic:\n int smallestEqual(vector& nums) \n {\n* int ans=INT_MAX;\n for(int i=0;i<nums.size();i++)\n {\n | mayanksamadhiya12345 | NORMAL | 2021-11-11T17:08:39.636709+00:00 | 2021-11-11T17:09:05.513003+00:00 | 61 | false | class Solution {\npublic:\n int smallestEqual(vector<int>& nums) \n {\n* int ans=INT_MAX;\n for(int i=0;i<nums.size();i++)\n {\n if(i%10==nums[i])\n {\n ans = min(ans,i);\n }\n }\n if(ans==INT_MAX)\n {\n return ... | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | Python easy code, beats 100% | python-easy-code-beats-100-by-vistrit-ahuc | \ndef smallestEqual(self, nums: List[int]) -> int:\n for i in range(len(nums)):\n if i%10==nums[i]: return i\n return -1\n | vistrit | NORMAL | 2021-11-09T04:24:08.707997+00:00 | 2021-11-09T04:24:08.708049+00:00 | 169 | false | ```\ndef smallestEqual(self, nums: List[int]) -> int:\n for i in range(len(nums)):\n if i%10==nums[i]: return i\n return -1\n``` | 1 | 0 | ['Python'] | 0 |
smallest-index-with-equal-value | Surprise from leetcode | surprise-from-leetcode-by-avinash1320-slh1 | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int i=0, ans=-1;\n for(i=0;i<nums.size();i++){\n if(i%10==num | avinash1320 | NORMAL | 2021-11-05T06:26:40.948718+00:00 | 2021-11-05T06:26:40.948776+00:00 | 48 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int i=0, ans=-1;\n for(i=0;i<nums.size();i++){\n if(i%10==nums[i]){\n ans=i;\n break;}\n }\n return ans;\n }\n};\n```\n\n##### I know it is a easy question but there is so... | 1 | 1 | ['C', 'C++'] | 1 |
smallest-index-with-equal-value | EZ Python Code For Beginners O(N) | ez-python-code-for-beginners-on-by-saumy-7hf6 | \nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n val=-1\n for i in range(len(nums)):\n if i%10==nums[i]:\n | SaumyaRai29 | NORMAL | 2021-11-05T06:18:42.141640+00:00 | 2021-11-05T06:18:42.141679+00:00 | 31 | false | ```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n val=-1\n for i in range(len(nums)):\n if i%10==nums[i]:\n val=i\n return val\n return val\n``` | 1 | 1 | ['Python'] | 0 |
smallest-index-with-equal-value | Kotlin | kotlin-by-armat-qpip | \nclass Solution {\n fun smallestEqual(nums: IntArray): Int =\n nums.withIndex()\n .find { (index, num) -> index % 10 == num }\n | armat | NORMAL | 2021-11-04T14:31:08.203316+00:00 | 2021-11-04T14:31:08.203348+00:00 | 27 | false | ```\nclass Solution {\n fun smallestEqual(nums: IntArray): Int =\n nums.withIndex()\n .find { (index, num) -> index % 10 == num }\n ?.index ?: -1\n}\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | Easy Java Solution | easy-java-solution-by-debankakhan-17ej | \nclass Solution {\n public int smallestEqual(int[] nums) {\n int k=0;\n int flag=0;\n int arr[]= new int[nums.length];\n for(int | DebankaKhan | NORMAL | 2021-11-04T04:50:05.894831+00:00 | 2021-11-04T04:50:05.894881+00:00 | 65 | false | ```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int k=0;\n int flag=0;\n int arr[]= new int[nums.length];\n for(int i=0;i<nums.length;i++){\n arr[k]= i%10;\n k++;\n }\n for(int i=0;i<nums.length;i++){\n if(nums[i]==arr[i]){\n... | 1 | 0 | [] | 1 |
smallest-index-with-equal-value | C++ | c-by-ujjwal2001kant-fnum | ```\nclass Solution {\npublic:\n int smallestEqual(vector& nums) {\n for(int i=0; i<nums.size(); i++)\n {\n if(i%10==nums[i])\n | ujjwal2001kant | NORMAL | 2021-11-02T20:05:40.305344+00:00 | 2021-11-02T20:05:40.305400+00:00 | 54 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int i=0; i<nums.size(); i++)\n {\n if(i%10==nums[i])\n return i;\n }\n return -1;\n }\n}; | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | who dont understand code | who-dont-understand-code-by-yaswanthkosu-yrcc | why these type of problems in contest \ni dont even understand problem | yaswanthkosuru | NORMAL | 2022-09-03T16:11:46.217406+00:00 | 2022-09-03T16:11:46.217446+00:00 | 4,613 | false | why these type of problems in contest \ni dont even understand problem | 125 | 10 | [] | 16 |
maximum-rows-covered-by-columns | Brute-Force + Bit Magic | brute-force-bit-magic-by-votrubac-f5b2 | \nLow constraints give away a brute-force solution.\n \nWe try all combinations of columns (using a bit mask), where the number of columns does not exceed co | votrubac | NORMAL | 2022-09-03T16:00:17.929657+00:00 | 2022-09-03T16:00:17.929688+00:00 | 5,633 | false | \nLow constraints give away a brute-force solution.\n \nWe try all combinations of columns (using a bit mask), where the number of columns does not exceed `cols`.\n \nFor each combination, we count covered rows, and return the maximum.\n \nAs an optimization, we can only consider bit masks with `cols` bits. We... | 62 | 1 | [] | 15 |
maximum-rows-covered-by-columns | Bit Masking | bit-masking-by-surajthapliyal-o7dt | Idea : Generate all possible combinations to select columns, then check what asked.\ni\'th bit in mask is set if we are considering taking that column, otherwis | surajthapliyal | NORMAL | 2022-09-03T16:02:44.193744+00:00 | 2022-09-03T16:25:01.185064+00:00 | 1,893 | false | **Idea** : Generate all possible combinations to select columns, then check what asked.\n*i\'th* bit in mask is set if we are considering taking that column, otherwise it will be zero.\n-Total of \'2 power columns\' `(1<<total_columns)` combinations are possible.\n\n```\nclass Solution {\n\n public int maximumRows(i... | 31 | 0 | [] | 6 |
maximum-rows-covered-by-columns | [C++] || Backtracking | c-backtracking-by-4byx-fnje | What is Asked ?\n We have to find the maximum rows in which all cells having 1 should be covered by column we picking\n\nHow to Do ?\n\n1. We make a recursive f | 4byx | NORMAL | 2022-09-03T16:23:29.741654+00:00 | 2022-09-03T16:43:58.189673+00:00 | 3,040 | false | **What is Asked ?**\n `We have to find the maximum rows in which all cells having 1 should be covered by column we picking`\n\n**How to Do ?**\n```\n1. We make a recursive function in which we will pick column and not pick it\n2. picking a column means we marked it as visited\n3. When we reached base case we will trave... | 24 | 1 | ['C'] | 7 |
maximum-rows-covered-by-columns | Python 3 || 5 lines, combinations || T/S: 99% / 92% | python-3-5-lines-combinations-ts-99-92-b-a05n | \nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n\t\n m, n, ans = len(mat), len(mat[0]), -inf\n \n fo | Spaulding_ | NORMAL | 2022-10-06T19:42:01.410134+00:00 | 2024-06-14T16:13:52.281465+00:00 | 480 | false | ```\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n\t\n m, n, ans = len(mat), len(mat[0]), -inf\n \n for comb in combinations(range(n),n-cols):\n \n ct = len(set(r for r in range(m) for c in comb if mat[r][c] == 1))\n\n ans = max(a... | 16 | 0 | ['Python'] | 0 |
maximum-rows-covered-by-columns | C++ Easy to Understand BackTracking Solution | c-easy-to-understand-backtracking-soluti-tvlu | Intuition: We will consider all possible combinations of choosing the "cols" amount of columns. For each such combination, we will find the number of covered r | n0IQ | NORMAL | 2022-09-03T17:33:01.777008+00:00 | 2024-10-09T18:48:01.173999+00:00 | 972 | false | Intuition: We will consider all possible combinations of choosing the "cols" amount of columns. For each such combination, we will find the number of covered rows and choose the combination that gives the maximum number of covered rows.\n\nApproach: For considering all possible combinations of choosing columns, let\'s... | 16 | 1 | ['Backtracking', 'Recursion', 'C'] | 4 |
maximum-rows-covered-by-columns | Brute Force || Java | brute-force-java-by-abdulazizms-6s4k | \n static int maximumRows(int[][] mat, int cols) {\n return getResult(mat, cols, new HashSet<Integer>(),0) ;\n }\n static int getResult(int [][] | abdulazizms | NORMAL | 2022-09-03T16:02:01.758973+00:00 | 2022-09-03T19:01:05.164300+00:00 | 1,058 | false | ```\n static int maximumRows(int[][] mat, int cols) {\n return getResult(mat, cols, new HashSet<Integer>(),0) ;\n }\n static int getResult(int [][] mat, int cols, Set<Integer> set, int x){\n int maxResult = 0;\n if(cols == 0){\n int count = 0;\n for(int i = 0; i < mat... | 9 | 2 | [] | 2 |
maximum-rows-covered-by-columns | C++ solution using backtracking DFS | c-solution-using-backtracking-dfs-by-dha-hs6y | We can use DFS with backtracking to fetch all the valid combinations for this problem that would be C(m, cols) = m! / ((m - cols)! * cols!) here C denotes Combi | dhavalkumar | NORMAL | 2022-09-03T22:12:21.774161+00:00 | 2022-09-03T22:12:21.774201+00:00 | 351 | false | We can use **DFS** with **backtracking** to fetch all the **valid combinations** for this problem that would be C(m, cols) = m! / ((m - cols)! * cols!) here C denotes Combination or Binomial Coefficient and m denotes number of columns. Then we calculate the answer for each valid combination and return the maximum of al... | 8 | 1 | ['Backtracking', 'Depth-First Search', 'C'] | 0 |
maximum-rows-covered-by-columns | C++ | Bit Masking | Faster than 100% | O(2^n * n) | c-bit-masking-faster-than-100-o2n-n-by-a-kd5j | Approach\n1. Convert each row into a decimal number and store in a vector.\n2. Then traverse over range 1 << size of column, to go through all permutations havi | ama29n | NORMAL | 2022-09-03T16:10:16.133917+00:00 | 2022-09-03T17:35:01.073071+00:00 | 901 | false | **Approach**\n1. Convert each row into a decimal number and store in a vector.\n2. Then traverse over range 1 << size of column, to go through all permutations having set_bits = cols. \n3. For each such permutation count number of elements in above generated vector which have set bits at same position.\n4. Store the ma... | 8 | 2 | ['C', 'Bitmask'] | 2 |
maximum-rows-covered-by-columns | C++ || Backtracking | c-backtracking-by-kbp12-cr8n | \nclass Solution {\npublic:\n int n,m,ans = 0;\n void recur(vector<vector<int>>& mat, vector<int>& col_arr, int idx, int remaining_cols){\n //if we | kbp12 | NORMAL | 2022-09-03T16:01:20.469517+00:00 | 2022-09-03T16:01:20.469566+00:00 | 948 | false | ```\nclass Solution {\npublic:\n int n,m,ans = 0;\n void recur(vector<vector<int>>& mat, vector<int>& col_arr, int idx, int remaining_cols){\n //if we have not selected cols columns then remaining_cols will be non zero and no updatation in ans;\n if(idx==m and remaining_cols!=0) return;\n //i... | 8 | 0 | ['Backtracking', 'C'] | 1 |
maximum-rows-covered-by-columns | Anyone has difficulty in understanding ? | anyone-has-difficulty-in-understanding-b-13an | A lot of time is wasted for the problem understanding! | vincent_great | NORMAL | 2022-09-03T16:29:48.883549+00:00 | 2022-09-03T16:31:17.589971+00:00 | 296 | false | A lot of time is wasted for the problem understanding! | 6 | 0 | [] | 1 |
maximum-rows-covered-by-columns | ✅C++ || EXPLAINED && CLEAN CODE || Pick-NotPick | c-explained-clean-code-pick-notpick-by-a-9hq0 | \n\nwe have to apple pick-notpick on the columns of the matrix and we have to select \'cols\' number of subsequence lets say you selected 0th and 2nd col in the | abhinav_0107 | NORMAL | 2022-09-03T16:02:58.608540+00:00 | 2022-09-03T16:29:15.136085+00:00 | 994 | false | \n\n***we have to apple pick-notpick on the columns of the matrix and we have to select \'cols\' number of subsequence lets say you selected 0th and 2nd col in the Example -1. Then we have to iterate over rows ... | 6 | 3 | ['Backtracking', 'Recursion', 'C', 'C++'] | 1 |
maximum-rows-covered-by-columns | Python Simple Solution | python-simple-solution-by-redheadphone-aa9i | \nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n n,m = len(mat),len(mat[0])\n ans = 0\n\n def check( | redheadphone | NORMAL | 2022-09-03T16:01:48.946715+00:00 | 2022-09-03T16:01:48.946761+00:00 | 900 | false | ```\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n n,m = len(mat),len(mat[0])\n ans = 0\n\n def check(state,row,rowIncludedCount):\n nonlocal ans\n if row==n:\n if sum(state)<=cols:\n ans = max(ans,rowIn... | 6 | 1 | ['Python', 'Python3'] | 0 |
maximum-rows-covered-by-columns | Recursion Solution , Pick and NotPick Accepted | recursion-solution-pick-and-notpick-acce-h0kv | \n public int maximumRows(int[][] mat, int cols) {\n\n return helper(0, cols, mat);\n }\n\n Set<Integer> set = new HashSet<>();\n\n int helper | mufassir | NORMAL | 2022-09-03T16:09:41.326680+00:00 | 2022-09-03T16:09:41.326713+00:00 | 481 | false | ```\n public int maximumRows(int[][] mat, int cols) {\n\n return helper(0, cols, mat);\n }\n\n Set<Integer> set = new HashSet<>();\n\n int helper(int col, int cols, int[][] mat) {\n if (cols == 0 || col == mat[0].length) {\n int res = count(mat);\n return res;\n }\n... | 5 | 0 | ['Recursion', 'Java'] | 1 |
maximum-rows-covered-by-columns | Simple solution | easy to understand | Combinations | simple-solution-easy-to-understand-combi-6qn3 | Just check all the combinations of column\n\n\n\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n m, n = len(mat), l | thoufic | NORMAL | 2022-09-03T16:04:27.879395+00:00 | 2022-09-03T16:57:48.810085+00:00 | 812 | false | Just check all the combinations of column\n\n```\n\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n m, n = len(mat), len(mat[0])\n maxRows = 0\n \n colToChoose = list(combinations(list(range(n)), cols))\n \n for col in colToChoose:\n ... | 5 | 1 | ['Python'] | 2 |
maximum-rows-covered-by-columns | generate every possible subset and check | generate-every-possible-subset-and-check-59p2 | \nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int m=mat.size(),n=mat[0].size(),ans=0;\n int mask=((1<<n | aman282571 | NORMAL | 2022-09-03T16:01:04.196884+00:00 | 2022-09-03T16:03:05.122011+00:00 | 840 | false | ```\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int m=mat.size(),n=mat[0].size(),ans=0;\n int mask=((1<<n)-1);\n // use mask to generate every possible columns combination\n while(mask){\n unordered_set<int>select;\n for(int i... | 5 | 0 | [] | 2 |
maximum-rows-covered-by-columns | Simple C++ solution | simple-c-solution-by-tars2412-ehpb | simple backtracking problem!!!\n\n1. mark the current column\'s 1\'s and reduce the number of cols you have and move onwards to other columns\n2. unmark the cur | tars2412 | NORMAL | 2022-09-03T16:00:46.781495+00:00 | 2022-09-03T16:04:10.247980+00:00 | 597 | false | simple backtracking problem!!!\n\n1. mark the current column\'s 1\'s and reduce the number of cols you have and move onwards to other columns\n2. unmark the current column\'s 1\'s and move onwards to other columns.\n3. base case is when you reach the end column or you don\'t have cols left to mark 1\'s.\n4. I later rea... | 5 | 0 | ['Backtracking'] | 0 |
maximum-rows-covered-by-columns | Brute-Force + Backtracking | brute-force-backtracking-by-pk_87-kgt4 | \nclass Solution {\nprivate:\n int n,m;\n unordered_map<int,vector<int>> col;\n int maxRow=0;\n \n void selectCol(int currCol,vector<int> selecte | pawan_mehta | NORMAL | 2022-11-15T07:58:39.660321+00:00 | 2022-11-15T07:58:39.660352+00:00 | 770 | false | ```\nclass Solution {\nprivate:\n int n,m;\n unordered_map<int,vector<int>> col;\n int maxRow=0;\n \n void selectCol(int currCol,vector<int> selectedCol,int numSelect,int colSize)\n {\n if(selectedCol.size() == numSelect)\n {\n unordered_set<int> selectedColSet;\n f... | 4 | 0 | ['C'] | 0 |
maximum-rows-covered-by-columns | 100% faster ,Brute force C++,Easy to Understand | 100-faster-brute-force-ceasy-to-understa-nuwq | Simply check for all the combinations of columns i.e, check for a set of coulms taken that how many rows are covered tht can be furthur checked by checking all | Xahoor72 | NORMAL | 2022-09-04T06:49:50.932373+00:00 | 2022-09-04T06:52:55.002275+00:00 | 81 | false | **Simply check for all the combinations of columns i.e, check for a set of coulms taken that how many rows are covered tht can be furthur checked by checking all the ones in a row are present in the selected columns or not if yes count++ and at last take the maximum of this count for all the combinations of coulmns gen... | 4 | 0 | ['Backtracking', 'C'] | 0 |
maximum-rows-covered-by-columns | C++ Bitmask O(n*2^n) 7ms | c-bitmask-on2n-7ms-by-pisces311-loq1 | Whenever you see n <= 12, start typing for (int mask = 0; mask < (1 << n); mask++).\nc++\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& ma | Pisces311 | NORMAL | 2022-09-03T16:02:48.747227+00:00 | 2022-09-03T19:27:48.406029+00:00 | 340 | false | Whenever you see `n <= 12`, start typing `for (int mask = 0; mask < (1 << n); mask++)`.\n``` c++\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int n = mat.size(), m = mat[0].size();\n vector<int> rows(n);\n for (int i = 0; i < n; i++) {\n for (in... | 4 | 1 | ['C', 'Bitmask'] | 2 |
maximum-rows-covered-by-columns | Backtracking | Simple | C++ | backtracking-simple-c-by-adi193-bdio | \nclass Solution {\npublic:\n void func(vector<vector<int>>& mat, int cols,vector <int> v,int idx,int &ans){\n if(cols==0){\n int cnt=0;\n | adi193 | NORMAL | 2022-09-03T16:01:25.590935+00:00 | 2022-09-03T16:01:25.590968+00:00 | 358 | false | ```\nclass Solution {\npublic:\n void func(vector<vector<int>>& mat, int cols,vector <int> v,int idx,int &ans){\n if(cols==0){\n int cnt=0;\n for(int i=0;i<mat.size();i++){\n int f=1;\n for(int j=0;j<mat[i].size();j++){\n if(mat[i][j]==1 &... | 4 | 1 | ['Backtracking', 'C++'] | 0 |
maximum-rows-covered-by-columns | ✅ One Line Solution | one-line-solution-by-mikposp-onfv | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)Code #1.1 - One LineTime complexity: O(comb∗m∗n). Sp | MikPosp | NORMAL | 2024-02-24T14:20:10.849061+00:00 | 2025-03-16T11:16:06.811973+00:00 | 48 | false | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)
# Code #1.1 - One Line
Time complexity: $$O(comb*m*n)$$. Space complexity: $$O(n)$$
```
class Solution:
def maximumRows(self, g: List[List[int]], k: int) -> int:
return max(sum(all(r[c]==0 for c in ... | 3 | 0 | ['Array', 'Matrix', 'Combinatorics', 'Python', 'Python3'] | 0 |
maximum-rows-covered-by-columns | Check all subsets using Bit Masking | check-all-subsets-using-bit-masking-by-h-4cwl | According to the problem if we select a set of columns then \n\nFor ith row(matrix[i]) to be valid:\n\n1. If the jth col is selected: \n we don\'t care if th | Harshyd26 | NORMAL | 2024-01-27T09:46:59.909793+00:00 | 2024-01-27T10:00:48.197128+00:00 | 116 | false | According to the problem if we select a set of columns then \n\n**For ith row(matrix[i]) to be valid:**\n\n**1. If the jth col is selected:** \n we don\'t care if there are `0` or `1` in matrix[i][j].\n**2. If the jth column is not selected**\n`if(matrix[i][j]==1)` then that row will be invalid for those set of sele... | 3 | 0 | ['Bit Manipulation', 'C++'] | 0 |
maximum-rows-covered-by-columns | [java] ✔one the easiest solution with Explanation [Pick || notPick] Approach. | java-one-the-easiest-solution-with-expla-5uez | Approach - if you look at problem in little deep , you can directly see that for each column we have two option\n1. pick that column (if picked then, go to next | atul-chaudhary | NORMAL | 2022-09-05T16:17:04.638298+00:00 | 2022-09-05T16:17:04.638340+00:00 | 150 | false | Approach - if you look at problem in little deep , you can directly see that for each column we have two option\n1. pick that column (if picked then, go to next index and increased the count of total picked column)\n2. Not pick that column (if not picked, got to next step in this case since we have not picked it total... | 3 | 0 | ['Java'] | 0 |
maximum-rows-covered-by-columns | C++ Solution | Easy to Understand | Using Backtracking | c-solution-easy-to-understand-using-back-lzur | In this problem we apply concept of recursion of take and non take because of small constraint.\nSteps\n1. first we make a recursive function \'fun\' in which w | devil_pratihar | NORMAL | 2022-09-04T06:27:22.162850+00:00 | 2022-09-04T06:28:42.816094+00:00 | 25 | false | In this problem we apply concept of recursion of take and non take because of small constraint.\n**Steps**\n**1.** first we make a recursive function \'fun\' in which we pass current index, given matrix, given cols and visited array.\n**2.** So visited array take care of column of matrix that which column is selected o... | 3 | 0 | ['Backtracking', 'Recursion', 'C'] | 0 |
maximum-rows-covered-by-columns | Python || recursion || backtracking | python-recursion-backtracking-by-1md3nd-lj9a | Backtracking + recursion\n## Time -> O(2^N) {N is length of columns}\n## Space -> O(cols)\n\n\nclass Solution:\n def maximumRows(self, mat: List[List[int]], | 1md3nd | NORMAL | 2022-09-03T20:52:07.091533+00:00 | 2022-09-03T20:52:07.091566+00:00 | 516 | false | # Backtracking + recursion\n## Time -> O(2^N) {N is length of columns}\n## Space -> O(cols)\n\n```\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n res = []\n M = len(mat)\n N = len(mat[0])\n def check(seen):\n count = 0\n for row i... | 3 | 0 | ['Backtracking', 'Recursion', 'Python', 'Python3'] | 0 |
maximum-rows-covered-by-columns | Easy C++ Explanation with comment | easy-c-explanation-with-comment-by-imdhr-4jpn | \n\nclass Solution {\n \n int f(vector<vector<int>>& mat, vector<int> &v, int r){\n \n int ans = 0;\n bool flag = true;\n \n | ImDhruba | NORMAL | 2022-09-03T18:01:09.243655+00:00 | 2022-09-03T18:06:55.296377+00:00 | 28 | false | ```\n\nclass Solution {\n \n int f(vector<vector<int>>& mat, vector<int> &v, int r){\n \n int ans = 0;\n bool flag = true;\n \n for(int i = 0; i < r; i++){\n \n\t\t\t/*\n\t\t\twe are taking each row at one time and iterating through it\t\t\t\n\t\t\t*/\n vec... | 3 | 0 | ['C++'] | 1 |
maximum-rows-covered-by-columns | C++ || 100% Fast || Easy To Understand | c-100-fast-easy-to-understand-by-geeksme-l3l9 | \nclass Solution {\npublic:\n // Global Vector to all possible column combinations\n vector<vector<int>>comb;\n\t\n // Function to find the number of r | geeksme123 | NORMAL | 2022-09-03T17:58:02.889857+00:00 | 2022-09-03T17:58:02.889922+00:00 | 352 | false | ```\nclass Solution {\npublic:\n // Global Vector to all possible column combinations\n vector<vector<int>>comb;\n\t\n // Function to find the number of rows a particular column combination can capture\n int find(vector<vector<int>>& mat1)\n {\n int c = 0;\n for(int i = 0; i < mat1.size(); ... | 3 | 0 | ['Backtracking', 'C', 'C++'] | 0 |
maximum-rows-covered-by-columns | 🤯 Simplest Python Solution | Brute Force | Combinations | simplest-python-solution-brute-force-com-qj20 | Upvote if you like\n\n\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n columns = [i for i in range(len(mat[0]))]\n | ramsudharsan | NORMAL | 2022-09-03T16:34:56.622828+00:00 | 2022-09-17T21:25:49.623071+00:00 | 201 | false | Upvote if you like\n\n```\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n columns = [i for i in range(len(mat[0]))]\n\t\t# All combinations of columns to select\n combos = combinations(columns, cols)\n ans = 0\n \n\t\t# For every combo try to count numb... | 3 | 0 | ['Python'] | 1 |
maximum-rows-covered-by-columns | Backtracking | Java Solution | Code with comments | backtracking-java-solution-code-with-com-vwso | Idea is to use backtraking. But before trying that we should know how to calculate which all rows are not covered by choosen columns. For that we can store this | anuj0503 | NORMAL | 2022-09-03T16:00:52.564621+00:00 | 2022-09-03T16:01:11.836938+00:00 | 401 | false | Idea is to use backtraking. But before trying that we should know how to calculate which all rows are not covered by choosen columns. For that we can store this info in a map (column index to set of row indices haiving one). For each possible combination in backtraking we calculate which all rows were missed and substr... | 3 | 0 | ['Backtracking', 'Java'] | 0 |
maximum-rows-covered-by-columns | Permutations v/s Subsets | permutations-vs-subsets-by-jay_1410-8f0a | 1. Using Subsets - \n- We can just simply Check all subsets which have K setbits (i.e K columns selected)\n- Time Complexity : O(2^(Columns) * Rows * Columns)\n | Jay_1410 | NORMAL | 2024-06-09T13:19:45.434426+00:00 | 2024-06-09T13:22:54.031545+00:00 | 249 | false | # 1. Using Subsets - \n- We can just simply Check all subsets which have K setbits (i.e K columns selected)\n- **Time Complexity :** O(2^(Columns) * Rows * Columns)\n- **Space Complexity :** O(1)\n```\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>> &A , int K){\n int Rows = A.size() , Cols = ... | 2 | 0 | ['Bit Manipulation', 'Combinatorics', 'Bitmask', 'C++', 'Java', 'Python3'] | 0 |
maximum-rows-covered-by-columns | C++ | Easy-Understanding Backtracking Solution | c-easy-understanding-backtracking-soluti-pt5x | \t#define ll int\n\tclass Solution {\n\tpublic:\n ll maxi =0;\n ll n,m;\n void f (ll col,ll curcol, vector> &mat, vector> &dummy){ \n if( | Kaustubh01 | NORMAL | 2022-09-07T16:44:14.762146+00:00 | 2022-09-07T16:44:14.762187+00:00 | 95 | false | \t#define ll int\n\tclass Solution {\n\tpublic:\n ll maxi =0;\n ll n,m;\n void f (ll col,ll curcol, vector<vector<int>> &mat, vector<vector<int>> &dummy){ \n if(col==0){\n ll rows =0; \n // count how many rows are filled with 0 values\n for(int i=0;i<n;i++){... | 2 | 0 | ['Backtracking', 'Recursion', 'C'] | 0 |
maximum-rows-covered-by-columns | JAVA | BACKTRACK | RECURSION | Runtime 1ms | 100% faster | java-backtrack-recursion-runtime-1ms-100-s7gz | This question is similar to 698. Partition to K Equal Sum Subsets.\nWe try all possible combinations of columns, once we select the given number of columns, we | raghavtilak | NORMAL | 2022-09-06T07:52:35.860829+00:00 | 2022-09-06T11:59:35.566174+00:00 | 200 | false | This question is similar to [698. Partition to K Equal Sum Subsets](https://leetcode.com/problems/partition-to-k-equal-sum-subsets/).\nWe try all possible combinations of columns, once we select the given number of columns, we check that for how many rows in the matrix, the below condition is true:-\n1. Each cell of th... | 2 | 0 | ['Backtracking', 'Recursion', 'Java'] | 0 |
maximum-rows-covered-by-columns | Simple backtracking java solution | simple-backtracking-java-solution-by-uts-zjsv | \nclass Solution { \n public int calculateNumberOfRows(int [][]mat,Set<Integer> cols){\n int n=mat.length,m=mat[0].length;\n int cnt=0;\n | utsavvjain | NORMAL | 2022-09-05T18:56:07.881895+00:00 | 2022-09-05T18:56:07.881932+00:00 | 139 | false | ```\nclass Solution { \n public int calculateNumberOfRows(int [][]mat,Set<Integer> cols){\n int n=mat.length,m=mat[0].length;\n int cnt=0;\n int i,j;\n for(i=0;i<n;i++){\n for(j=0;j<m;j++) {\n if(mat[i][j]==1 && !cols.contains(j)) break;\n }\n ... | 2 | 0 | ['Backtracking', 'Java'] | 0 |
maximum-rows-covered-by-columns | C++ Easy Solution | c-easy-solution-by-mdaparnay23-j46n | \nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& v, int k) {\n int n=v.size(),m=v[0].size();\n int ans=0;\n for(int i= | mdaparnay23 | NORMAL | 2022-09-04T05:30:11.398814+00:00 | 2022-09-04T05:30:11.398858+00:00 | 90 | false | ```\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& v, int k) {\n int n=v.size(),m=v[0].size();\n int ans=0;\n for(int i=0;i<(1<<12);i++){\n string s="";\n int c=0;\n for(int j=0;j<12;j++){\n if(i&(1<<j)) s+=\'1\';\n ... | 2 | 0 | [] | 0 |
maximum-rows-covered-by-columns | C++ | Simple Next Permutation | No Bit Masking or Back Tracking | c-simple-next-permutation-no-bit-masking-iocm | The idea is to just try all the combinations of the columns(with maximum cols columns selected) and see how many rows are being covered.\n\nWe can generate all | nisaanthdunnu | NORMAL | 2022-09-03T23:43:39.315862+00:00 | 2022-09-03T23:43:39.315897+00:00 | 52 | false | The idea is to just try all the combinations of the columns(with maximum ***cols*** columns selected) and see how many rows are being covered.\n\nWe can generate all the permutations using C++ next_permutation() algorithm starting from the first permutation when lexicographically sorted.\n\n\n```\nint maximumRows(vecto... | 2 | 0 | ['C'] | 0 |
maximum-rows-covered-by-columns | python brute force | python-brute-force-by-akaghosting-9tg5 | \tclass Solution:\n\t\tdef maximumRows(self, mat: List[List[int]], cols: int) -> int:\n\t\t\tm = len(mat)\n\t\t\tn = len(mat[0])\n\t\t\tres = 0\n\t\t\tfor combi | akaghosting | NORMAL | 2022-09-03T19:47:13.551883+00:00 | 2022-09-03T20:38:28.406153+00:00 | 68 | false | \tclass Solution:\n\t\tdef maximumRows(self, mat: List[List[int]], cols: int) -> int:\n\t\t\tm = len(mat)\n\t\t\tn = len(mat[0])\n\t\t\tres = 0\n\t\t\tfor combination in combinations(range(n), cols):\n\t\t\t\tcnt = 0\n\t\t\t\tfor i in range(m):\n\t\t\t\t\tcheck = True\n\t\t\t\t\tfor j in range(n):\n\t\t\t\t\t\tif mat[i... | 2 | 0 | [] | 1 |
maximum-rows-covered-by-columns | C++ Solution | c-solution-by-travanj05-h3zo | cpp\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>> &mat, int cols) {\n int m = mat.size(), n = mat[0].size();\n int perm = po | travanj05 | NORMAL | 2022-09-03T18:25:36.034676+00:00 | 2022-09-03T18:25:36.034721+00:00 | 34 | false | ```cpp\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>> &mat, int cols) {\n int m = mat.size(), n = mat[0].size();\n int perm = pow(2, n) - 1;\n vector<vector<int>> grid(perm + 1, vector<int>(n, 0));\n for (int i = 0; i <= perm; i++) {\n for (int j = 0; j < n; j... | 2 | 0 | ['C', 'C++'] | 0 |
maximum-rows-covered-by-columns | ✅✅Faster || Easy To Understand || C++ Code | faster-easy-to-understand-c-code-by-__kr-keah | Backtracking\n\n Time Complexity :- O(N * M * 2 ^ M)\n\n Space Complexity :- O(N * M * 2 ^ M)\n\n\nclass Solution {\npublic:\n \n // res will store all th | __KR_SHANU_IITG | NORMAL | 2022-09-03T17:32:16.885316+00:00 | 2022-09-03T17:32:16.885364+00:00 | 142 | false | * ***Backtracking***\n\n* ***Time Complexity :- O(N * M * 2 ^ M)***\n\n* ***Space Complexity :- O(N * M * 2 ^ M)***\n\n```\nclass Solution {\npublic:\n \n // res will store all the subsequence of size k\n \n vector<vector<int>> res;\n \n vector<int> curr;\n \n // function for finding subsequence... | 2 | 0 | ['Backtracking', 'Recursion', 'C', 'C++'] | 0 |
maximum-rows-covered-by-columns | Backtracking C++ | backtracking-c-by-07ritvik-x1m2 | Logic :\n1. We have to take cols no. of columns so we have choice whether to take a particular column or not.\n2. If we chose a particular column ind then we ma | 07ritvik | NORMAL | 2022-09-03T16:45:36.685332+00:00 | 2022-09-03T16:46:23.259752+00:00 | 73 | false | Logic :\n1. We have to take **cols** no. of columns so we have choice whether to take a particular column or not.\n2. If we chose a particular column **ind** then we make all the elements of the rows in which column value is **ind**.\n3. If we do not chose this column then we will backtrack and unvisit the elements whi... | 2 | 0 | ['C'] | 1 |
maximum-rows-covered-by-columns | Python | Simple and straightforward | Combinations | Explained | python-simple-and-straightforward-combin-zjks | \nfrom itertools import combinations\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n rows = 0\n \n # | kajabraz | NORMAL | 2022-09-03T16:33:28.649526+00:00 | 2023-08-30T00:19:51.363709+00:00 | 227 | false | ```\nfrom itertools import combinations\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n rows = 0\n \n # iterate over each combintion of the given numer of columns\n # the first argument passed to combinations is the list of columns\' indices\n # ... | 2 | 0 | ['Python', 'Python3'] | 1 |
maximum-rows-covered-by-columns | Cpp solution | cpp-solution-by-user2349xl-lt20 | \nclass Solution {\npublic:\n \n typedef long long ll;\n vector<int> v;\n int dp[13][4097][13];\n int m, n;\n\t\n int maximumRows(vector<vecto | ninaiway | NORMAL | 2022-09-03T16:22:40.567613+00:00 | 2022-09-03T16:36:16.103617+00:00 | 117 | false | ```\nclass Solution {\npublic:\n \n typedef long long ll;\n vector<int> v;\n int dp[13][4097][13];\n int m, n;\n\t\n int maximumRows(vector<vector<int>>& mat, int cols) {\n \n m = mat.size();\n n = mat[0].size();\n \n for (int i =0; i < m; i++) {\n \n ... | 2 | 0 | ['Dynamic Programming', 'Bit Manipulation', 'Depth-First Search', 'C++'] | 0 |
maximum-rows-covered-by-columns | Whoever understand this is a god ✅ JavaScript | Combinations | whoever-understand-this-is-a-god-javascr-xoph | FYI, I wrote this solutions and got accepted (just 4 sec before end time) in biweekly contest 86. I understand the code is very brute force. Anyway I\'m trying | thakurballary | NORMAL | 2022-09-03T16:13:08.566598+00:00 | 2022-09-03T17:43:28.206191+00:00 | 338 | false | FYI, I wrote this solutions and got accepted (just 4 sec before end time) in biweekly contest 86. I understand the code is very brute force. Anyway I\'m trying to improve my skills. So, ya enjoy reading my solution and if you understand it, now only god, you and I know it :)\n```\n/**\n * @param {number[][]} mat\n * @p... | 2 | 0 | ['JavaScript'] | 5 |
maximum-rows-covered-by-columns | easy short clean code | easy-short-clean-code-by-maverick09-yvst | \nclass Solution {\npublic:\n int m, n, res;\n long long func(const vector<vector<int>>& v, int c, const int&x, int bm) {\n if (__builtin_popcount( | maverick09 | NORMAL | 2022-09-03T16:02:52.346877+00:00 | 2022-09-03T16:02:52.346965+00:00 | 235 | false | ```\nclass Solution {\npublic:\n int m, n, res;\n long long func(const vector<vector<int>>& v, int c, const int&x, int bm) {\n if (__builtin_popcount(bm) == x) {\n int ans = m;\n for (int i = 0;i < m;++i) {\n for (int j = 0;j < n;++j) {\n if (v[i][j] ... | 2 | 0 | ['Backtracking', 'C'] | 0 |
maximum-rows-covered-by-columns | Basic C++ Backtracking & Recursive Approach. | basic-c-backtracking-recursive-approach-njr04 | Intuition
Given a binary matrix (matrix) and a number numSelect, we need to select numSelect columns such that the maximum number of fully covered rows is achi | Sujal049 | NORMAL | 2025-04-03T18:17:49.984327+00:00 | 2025-04-03T18:17:49.984327+00:00 | 11 | false | # Intuition
- Given a binary matrix (matrix) and a number numSelect, we need to select numSelect columns such that the maximum number of fully covered rows is achieved.
- A row is covered if all 1s in that row exist in at least one of the selected columns.
- The goal is to maximize the number of fully covered rows.
... | 1 | 0 | ['Backtracking', 'Recursion', 'Matrix', 'C++'] | 0 |
maximum-rows-covered-by-columns | Easy C++ Solution using Bitmask and Backtracking | easy-c-solution-using-bitmask-and-backtr-wysp | 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 | Ronit_0109 | NORMAL | 2024-06-13T19:47:54.791604+00:00 | 2024-06-13T19:47:54.791635+00:00 | 7 | false | # 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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Backtracking', 'Bit Manipulation', 'Bitmask', 'C++'] | 0 |
maximum-rows-covered-by-columns | Brute force using Backtracking | C++ | brute-force-using-backtracking-c-by-whoa-9qfr | I tried generating all possible combination of numSelect columns using the f( ) function using backtracking. Then just iteraterd over the matrix for each combin | whoami950 | NORMAL | 2023-06-01T18:15:14.713242+00:00 | 2023-06-01T18:15:14.713279+00:00 | 16 | false | I tried generating all possible combination of **numSelect** columns using the `f( )` function using backtracking. Then just iteraterd over the matrix for each combination of columns, checked the given condition which just says that if the cell is equal to 1 then it has to be a part of the column selected by current co... | 1 | 0 | ['C++'] | 0 |
maximum-rows-covered-by-columns | c++ | easy to undersatand | step by step | c-easy-to-undersatand-step-by-step-by-ve-jc95 | ```\nclass Solution {\npublic:\n int n, ans=0;\n vector row_sums;\n \n int sumOfRow(vector &vec){\n int res=0;\n for(auto a:vec) res+= | venomhighs7 | NORMAL | 2022-09-27T12:15:45.377501+00:00 | 2022-09-27T12:15:45.377536+00:00 | 47 | false | ```\nclass Solution {\npublic:\n int n, ans=0;\n vector<int> row_sums;\n \n int sumOfRow(vector<int> &vec){\n int res=0;\n for(auto a:vec) res+=a;\n return res;\n }\n \n int isPossible(vector<int> &a, vector<int> &b){\n int res=0;\n for(int i=0; i<a.size(); i++){\... | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | Maximum Rows Covered by Columns Solution Java | maximum-rows-covered-by-columns-solution-3v2a | class Solution {\n public int maximumRows(int[][] matrix, int numSelect) {\n dfs(matrix, /colIndex=/0, numSelect, /mask=/0);\n return ans;\n }\n\n priv | bhupendra786 | NORMAL | 2022-09-18T12:07:30.631514+00:00 | 2022-09-18T12:07:30.631559+00:00 | 47 | false | class Solution {\n public int maximumRows(int[][] matrix, int numSelect) {\n dfs(matrix, /*colIndex=*/0, numSelect, /*mask=*/0);\n return ans;\n }\n\n private int ans = 0;\n\n private void dfs(int[][] matrix, int colIndex, int leftColsCount, int mask) {\n if (leftColsCount == 0) {\n ans = Math.max(ans... | 1 | 0 | ['Array', 'Backtracking', 'Bit Manipulation', 'Matrix', 'Enumeration'] | 0 |
maximum-rows-covered-by-columns | No backtracking ❌ | Do bit manipulation✅ | no-backtracking-do-bit-manipulation-by-n-0sr1 | \n\t\tclass Solution:\n\t\t\tdef maximumRows(self, matrix: List[List[int]], numSelect: int) -> int:\n\t\t\t\tn = len(matrix)\n\t\t\t\ta = [int(\'\'.join([str(j) | NaveenprasanthSA | NORMAL | 2022-09-16T11:54:32.802077+00:00 | 2022-09-16T11:54:32.802119+00:00 | 72 | false | \n\t\tclass Solution:\n\t\t\tdef maximumRows(self, matrix: List[List[int]], numSelect: int) -> int:\n\t\t\t\tn = len(matrix)\n\t\t\t\ta = [int(\'\'.join([str(j) for j in matrix[i]]),2) for i in range(n)]\n\t\t\t\tres = 0\n\t\t\t\tfor i in range(n):\n\t\t\t\t\tans = a[i] \n\t\t\t\t\tcur = 0\n\t\t\t\t\tfor j in range(n):... | 1 | 0 | ['Python'] | 0 |
maximum-rows-covered-by-columns | Combinations and issubset(), 77% speed | combinations-and-issubset-77-speed-by-ev-e6nv | \n\nclass Solution:\n def maximumRows(self, matrix: List[List[int]], numSelect: int) -> int:\n ans = 0\n m_ones = [{i for i, v in enumerate(row | evgenysh | NORMAL | 2022-09-12T10:49:21.250389+00:00 | 2022-09-12T10:52:17.712809+00:00 | 65 | false | \n```\nclass Solution:\n def maximumRows(self, matrix: List[List[int]], numSelect: int) -> int:\n ans = 0\n m_ones = [{i for i, v in enumerate(row) if v} for row in matrix]\n for comb in... | 1 | 0 | ['Python', 'Python3'] | 0 |
maximum-rows-covered-by-columns | How is it in the medium category | how-is-it-in-the-medium-category-by-hash-shod | Like seiously, after wasting a day and a half pondering upon a consize and effective approach, this problem turns out to be a basic bruteforce backtracking prob | Hash_coder27 | NORMAL | 2022-09-11T19:31:52.769392+00:00 | 2022-09-11T19:32:33.598720+00:00 | 73 | false | Like seiously, after wasting a day and a half pondering upon a consize and effective approach, this problem turns out to be a basic bruteforce backtracking problem!!!\nTotally annoying | 1 | 1 | [] | 1 |
maximum-rows-covered-by-columns | Python Brute Force | python-brute-force-by-maelseifi-3w21 | ```\nm = len(matrix)\n n = len(matrix[0])\n colcombs = list(itertools.combinations(list(range(n)), numSelect))\n \n maxcovered = 0\n | maelseifi | NORMAL | 2022-09-09T18:43:30.869550+00:00 | 2022-09-09T18:43:30.869599+00:00 | 76 | false | ```\nm = len(matrix)\n n = len(matrix[0])\n colcombs = list(itertools.combinations(list(range(n)), numSelect))\n \n maxcovered = 0\n for i in range(len(colcombs)):\n covered = 0\n for j in range(m):\n flag = 0\n if all(x == 0 for x i... | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | C++| Brute-Force | c-brute-force-by-kumarabhi98-i8jr | \nclass Solution {\npublic:\n int no(int n){\n int re = 0;\n while(n){ n = n&(n-1); re++;} return re;\n }\n \n int find(vector<vector | kumarabhi98 | NORMAL | 2022-09-06T13:39:32.085297+00:00 | 2022-09-06T13:39:32.085322+00:00 | 56 | false | ```\nclass Solution {\npublic:\n int no(int n){\n int re = 0;\n while(n){ n = n&(n-1); re++;} return re;\n }\n \n int find(vector<vector<int>>& nums,int bit){\n unordered_set<int> st;\n for(int i = 0; i<nums.size();++i){\n for(int j = 0; j<nums[0].size();++j){\n ... | 1 | 0 | ['C', 'Bitmask'] | 0 |
maximum-rows-covered-by-columns | My Java Solution | my-java-solution-by-akash_nad-2i2q | Time Complexity is probably Exponential but I can\'t say the exact figure.\nSpace Complexity: O(N - cols)\n\nclass Solution {\n int M, N;\n public int max | Akash_Nad | NORMAL | 2022-09-06T09:44:42.188605+00:00 | 2022-09-06T09:44:42.188648+00:00 | 64 | false | ***Time Complexity is probably Exponential but I can\'t say the exact figure.***\n***Space Complexity: O(N - cols)***\n```\nclass Solution {\n int M, N;\n public int maximumRows(int[][] mat, int cols) {\n M = mat.length;\n N = mat[0].length;\n if(cols == N) return M;\n return findMaxRo... | 1 | 0 | ['Backtracking', 'Java'] | 0 |
maximum-rows-covered-by-columns | Python3 Solution | Very Easy Approach | python3-solution-very-easy-approach-by-t-wx91 | The solution is very simple:\nFirst we will find all the combinations, and then we will iterate over all the combinations of the array. At each iteration, check | triposat | NORMAL | 2022-09-05T10:08:15.189845+00:00 | 2022-09-05T10:09:28.730566+00:00 | 75 | false | *The solution is very simple:*\n**First we will find all the combinations, and then we will iterate over all the combinations of the array. At each iteration, check every row and cols.**\n\n\tclass Solution:\n\t\tdef maximumRows(self, mat: List[List[int]], cols: int) -> int:\n\t\t\tallCombinations = []\n\n\t\t\tdef com... | 1 | 0 | ['Python', 'Python3'] | 0 |
maximum-rows-covered-by-columns | Accepted Solution | Using Recursion | C++ | accepted-solution-using-recursion-c-by-p-olvz | \nclass Solution {\nprivate:\n int maxi = INT_MIN;\n int checkMax(int& m, int& n, vector<vector<int>>& mat, vector<bool>& visCols){\n int count=0;\ | parasgaur24 | NORMAL | 2022-09-05T08:00:29.071064+00:00 | 2022-09-05T08:01:39.592549+00:00 | 14 | false | ```\nclass Solution {\nprivate:\n int maxi = INT_MIN;\n int checkMax(int& m, int& n, vector<vector<int>>& mat, vector<bool>& visCols){\n int count=0;\n \n for(int i=0;i<m;i++){\n bool flag=true;\n for(int j=0;j<n;j++){\n if(mat[i][j]==1 && visCols[j]==fals... | 1 | 0 | ['Recursion', 'C'] | 0 |
maximum-rows-covered-by-columns | C++ | Bitmask | c-bitmask-by-rachit759-7de8 | \nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int m(size(mat)), n(size(mat[0]));\n int ans = 0, rows;\n | rachit759 | NORMAL | 2022-09-05T00:27:14.913618+00:00 | 2022-09-05T01:00:03.750933+00:00 | 44 | false | ```\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int m(size(mat)), n(size(mat[0]));\n int ans = 0, rows;\n bool flag;\n for(int mask = 1; mask <= (1<<n); mask++) {\n if(__builtin_popcount(mask) != cols) continue; \n vector<int>... | 1 | 0 | ['C', 'Bitmask'] | 0 |
maximum-rows-covered-by-columns | Simple Backtracking c++ | simple-backtracking-c-by-aditya_h-r34s | ```\nclass Solution {\npublic:\n void pickcolumn(int i,vector>& mat, int cols,int currcols, vector&visited, int &ans){\n if(i==mat[0].size()){\n | Aditya_H | NORMAL | 2022-09-04T16:14:41.266163+00:00 | 2022-09-04T16:14:41.266202+00:00 | 32 | false | ```\nclass Solution {\npublic:\n void pickcolumn(int i,vector<vector<int>>& mat, int cols,int currcols, vector<bool>&visited, int &ans){\n if(i==mat[0].size()){\n int count=0;\n for(int i=0;i<mat.size();i++){\n bool flag=true;\n for(int j=0;j<mat[0].size();j... | 1 | 0 | ['Backtracking', 'Recursion'] | 0 |
maximum-rows-covered-by-columns | C++ || backtracking || intuitive approach || 4 ms | c-backtracking-intuitive-approach-4-ms-b-z9ea | Try all possible combination of columns \n* Check against each combination of columns for the maximum covered rows\n\n\nclass Solution {\npublic:\n int solve | gourav0sharma1 | NORMAL | 2022-09-04T07:10:28.228518+00:00 | 2022-09-04T07:10:28.228570+00:00 | 23 | false | * Try all possible combination of columns \n* Check against each combination of columns for the maximum covered rows\n\n```\nclass Solution {\npublic:\n int solve(vector<vector<int>> &mat, int curCol , int column, vector<int> &selectedColumn){\n \n if(column == 0){\n int count = 0;\n ... | 1 | 0 | ['Backtracking', 'C'] | 0 |
maximum-rows-covered-by-columns | Super Easy Recursive Code || Java | super-easy-recursive-code-java-by-lil_to-aeau | \nclass Solution {\n int m,n,res = 0, arr[], cols,mat[][];\n public int maximumRows(int[][] mat, int cols) {\n m = mat.length;\n n = mat[0]. | Lil_ToeTurtle | NORMAL | 2022-09-04T06:30:08.460959+00:00 | 2022-09-04T06:30:08.461000+00:00 | 241 | false | ```\nclass Solution {\n int m,n,res = 0, arr[], cols,mat[][];\n public int maximumRows(int[][] mat, int cols) {\n m = mat.length;\n n = mat[0].length;\n this.cols = cols;\n arr = new int[cols];\n this.mat = mat;\n recurse(-1,-1);\n return res;\n }\n \n voi... | 1 | 0 | ['Recursion', 'Java'] | 1 |
maximum-rows-covered-by-columns | brute force recursive solution || 100%fast | brute-force-recursive-solution-100fast-b-0ved | \n | Am_Shubh_07_06 | NORMAL | 2022-09-03T20:33:00.974000+00:00 | 2022-09-03T20:33:00.974036+00:00 | 13 | false | \n | 1 | 0 | ['Backtracking', 'Recursion'] | 1 |
maximum-rows-covered-by-columns | Backtracking || Trying all combinations of cols | backtracking-trying-all-combinations-of-29l9u | \nclass Solution {\npublic:\n void solve(vector<vector<int>>&nums, vector<int> temp, int i, int cols, int m){\n \n if(i==m){\n if(te | bhomik23 | NORMAL | 2022-09-03T20:26:57.461152+00:00 | 2022-09-03T20:26:57.461182+00:00 | 62 | false | ```\nclass Solution {\npublic:\n void solve(vector<vector<int>>&nums, vector<int> temp, int i, int cols, int m){\n \n if(i==m){\n if(temp.size() == cols)\n nums.push_back(temp);\n \n return ;\n }\n \n // dont take this column\n ... | 1 | 0 | ['Backtracking', 'Recursion', 'C', 'C++'] | 0 |
maximum-rows-covered-by-columns | JAVA EASY SOLUTION | java-easy-solution-by-abhizz-tha2 | \nclass Solution {\n public int maximumRows(int[][] mat, int cols) {\n int rows = mat.length;\n int col = mat[0].length;\n int res = 0;\ | abhizz | NORMAL | 2022-09-03T18:40:11.884790+00:00 | 2022-09-03T18:40:11.884837+00:00 | 115 | false | ```\nclass Solution {\n public int maximumRows(int[][] mat, int cols) {\n int rows = mat.length;\n int col = mat[0].length;\n int res = 0;\n for(int i = 0; i < (1<<col); i++) {\n if(getCount(i) == cols) {\n int cnt = 0;\n for(int r = 0; r < rows; r... | 1 | 0 | ['Bitmask', 'Java'] | 0 |
maximum-rows-covered-by-columns | Bit Masking+ Implementation (Easy understanding) | C++ | bit-masking-implementation-easy-understa-t2zm | I have used concept of bitmasking:\n1. Convert each row into a number(convert binary to decimal)\n2. Then we select column by using set bits of 1 to 2^(number o | automata_1 | NORMAL | 2022-09-03T18:09:44.058686+00:00 | 2022-09-03T18:09:44.058733+00:00 | 49 | false | I have used concept of bitmasking:\n1. Convert each row into a number(convert binary to decimal)\n2. Then we select column by using set bits of 1 to 2^(number of columns)[concept of subset generation]\n3. Then take ```AND``` and then see if the count of bits is same or not. \n\nEx: \n0 0 0 -> 0\n1 0 1 -> 5\n0 1 1 -> 3\... | 1 | 0 | ['C', 'Bitmask'] | 0 |
maximum-rows-covered-by-columns | Simple Intuition NO BITS - Backtracking | simple-intuition-no-bits-backtracking-by-vfxd | \nclass Solution {\n public int maximumRows(int[][] mat, int cols) {\n int m = mat.length;\n int n = mat[0].length;\n \n int ones | vedwaj | NORMAL | 2022-09-03T18:04:36.865386+00:00 | 2022-09-03T18:04:36.865432+00:00 | 322 | false | ```\nclass Solution {\n public int maximumRows(int[][] mat, int cols) {\n int m = mat.length;\n int n = mat[0].length;\n \n int onesInRow[] = new int[m];\n //counting number of ones in each row \n List<List<Integer>> onesInCol = new ArrayList<>();\n \n ... | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | Plz Anyone explain me the question first! | plz-anyone-explain-me-the-question-first-yjpy | Please anyone explain me the question. Thanks in advance! | cube_red | NORMAL | 2022-09-03T17:38:30.731606+00:00 | 2022-09-03T17:38:30.731644+00:00 | 23 | false | Please anyone explain me the question. Thanks in advance! | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | [JAVA] Beats 100%, BitMask + Backtraking, O(N!/(N-C)!) | java-beats-100-bitmask-backtraking-onn-c-lf4i | \nclass Solution {\n \n private int ans;\n \n public int maximumRows(int[][] mat, int cols) {\n var masks = new int[mat.length];\n // | yurokusa | NORMAL | 2022-09-03T17:24:23.915471+00:00 | 2022-09-03T17:45:01.276209+00:00 | 31 | false | ```\nclass Solution {\n \n private int ans;\n \n public int maximumRows(int[][] mat, int cols) {\n var masks = new int[mat.length];\n // convert every row to bitmask\n for (int r = 0; r < mat.length; r++) {\n var mask = 0;\n for (int c = 0; c < mat[r].length; c++)\... | 1 | 0 | ['Java'] | 0 |
maximum-rows-covered-by-columns | I did not understand the question.....please help | i-did-not-understand-the-questionplease-0q2b7 | Did anyone understand the problem????? | pratosh | NORMAL | 2022-09-03T17:19:26.944589+00:00 | 2022-09-03T17:19:26.944629+00:00 | 13 | false | Did anyone understand the problem????? | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | Bit Manipulation + Brute Force | bit-manipulation-brute-force-by-draxkira-8n77 | \nclass Solution {\npublic:\n \n int nost(int &n){\n int a=0;\n for(int i = 0 ; i<32; i++){\n if(n&(1<<i))a++;\n \n | draxkira | NORMAL | 2022-09-03T17:11:46.978534+00:00 | 2022-09-03T17:11:46.978573+00:00 | 28 | false | ```\nclass Solution {\npublic:\n \n int nost(int &n){\n int a=0;\n for(int i = 0 ; i<32; i++){\n if(n&(1<<i))a++;\n \n }\n return a;\n }\n \n int maximumRows(vector<vector<int>>& mat, int cols) {\n int n = mat[0].size();\n int m = mat.size()... | 1 | 0 | ['Bit Manipulation'] | 0 |
maximum-rows-covered-by-columns | For those who are finding it difficult to understand the problem statement! | for-those-who-are-finding-it-difficult-t-61ny | To simplify this question \nGiven a matrix of n rows and m columns, and provided input coll(which is the number of columns you have to pick) , you can choose a | ninja_01 | NORMAL | 2022-09-03T17:05:48.793831+00:00 | 2022-09-03T17:11:07.989562+00:00 | 27 | false | ## To simplify this question \nGiven a matrix of **n** rows and **m** columns, and provided input **col**l(*which is the number of columns you have to pick*) , you can choose any combination of colums (example say you have a matrix of columns 3) and given col input is 2 you can either choose **(12 , 13 , 23)** ie **3C... | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | forcest brute of all brute forces | forcest-brute-of-all-brute-forces-by-abh-8ohf | \nclass Solution {\npublic:\n int ans = -1;\n int res(int i,vector<int> v,vector<vector<int>>& mat,int cols)\n {\n if(i==mat[0].size())\n | abhinavsingh15682 | NORMAL | 2022-09-03T16:53:01.282860+00:00 | 2022-09-03T16:53:01.282894+00:00 | 19 | false | ```\nclass Solution {\npublic:\n int ans = -1;\n int res(int i,vector<int> v,vector<vector<int>>& mat,int cols)\n {\n if(i==mat[0].size())\n {\n int ch=0;\n for(int i=0;i<v.size();i++)\n if(v[i]==1)\n ch++;\n if(ch==cols)\n ... | 1 | 0 | [] | 1 |
maximum-rows-covered-by-columns | Bitmasking | C++ | bitmasking-c-by-mostafa_abdullah-di8w | \nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int n = mat.size(), m = mat[0].size();\n int len = (1 << | mostafa_abdullah | NORMAL | 2022-09-03T16:37:55.302856+00:00 | 2022-09-03T16:40:27.238183+00:00 | 17 | false | ```\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n int n = mat.size(), m = mat[0].size();\n int len = (1 << m), ans = 0;\n for (int x = 1; x < len; x++)\n {\n // if the number of chosen columns does not equal cols skip it\n if (_... | 1 | 0 | [] | 0 |
maximum-rows-covered-by-columns | C++| Backtracking | Very Easy Code | c-backtracking-very-easy-code-by-ankit46-cm99 | Please Upvote :)\n\n\nclass Solution {\npublic:\n int res=0;\n int maximumRows(vector<vector<int>>& mat, int cols) {\n unordered_map<int,int> m;\n | ankit4601 | NORMAL | 2022-09-03T16:30:38.521984+00:00 | 2022-09-03T16:30:38.522014+00:00 | 84 | false | Please Upvote :)\n\n```\nclass Solution {\npublic:\n int res=0;\n int maximumRows(vector<vector<int>>& mat, int cols) {\n unordered_map<int,int> m;\n fun(mat,m,cols,0);\n return res;\n }\n void fun(vector<vector<int>>& mat,unordered_map<int,int>& m,int cols,int i)\n {\n if(col... | 1 | 0 | ['Backtracking', 'Recursion', 'C', 'C++'] | 0 |
maximum-rows-covered-by-columns | Backtracking+ set | backtracking-set-by-comder_00-52fh | Okay so, I will tell you my simple approach for this question.\nI came up with this approach after I saw theconstraints at the contest.\nBasically the solution | comder_00 | NORMAL | 2022-09-03T16:27:44.333870+00:00 | 2022-09-03T16:27:44.333902+00:00 | 10 | false | Okay so, I will tell you my simple approach for this question.\nI came up with this approach after I saw theconstraints at the contest.\nBasically the solution is:-\n1. select all the sets of columns of size cols.\n2. For each set count the number of covered rows \n3. keep a counter to count the maximum.\n```\nclass So... | 1 | 0 | ['Backtracking', 'Ordered Set'] | 0 |
maximum-rows-covered-by-columns | Ruby | 100% | Bit mask | ruby-100-bit-mask-by-agentivan-lyao | Runtime: 192 ms, faster than 100.00% of Ruby online submissions\n#### Memory Usage: 211.1 MB, less than 100.00% of Ruby online submissions\nruby\ndef maximum_ro | AgentIvan | NORMAL | 2022-09-03T16:23:29.859604+00:00 | 2022-09-03T17:44:40.726137+00:00 | 16 | false | #### Runtime: 192 ms, faster than 100.00% of Ruby online submissions\n#### Memory Usage: 211.1 MB, less than 100.00% of Ruby online submissions\n```ruby\ndef maximum_rows(mat, cols)\n m, n, max = mat.length, mat[0].length, 0\n ints = mat.map{ _1.reduce(0) { |s, n| s * 2 + n }} # int form line of bits\n [*0...n].com... | 1 | 0 | ['Bitmask', 'Ruby'] | 2 |
maximum-rows-covered-by-columns | C# Solution .✅❇️ | c-solution-by-arafatsabbir-4b23 | \npublic int MaximumRows(int[][] mat, int cols) {\n var m = mat.Length;\n var n = mat[0].Length;\n var max = 0;\n for (var i = 0; i | arafatsabbir | NORMAL | 2022-09-03T16:13:33.222196+00:00 | 2022-09-04T15:49:40.170082+00:00 | 72 | false | ```\npublic int MaximumRows(int[][] mat, int cols) {\n var m = mat.Length;\n var n = mat[0].Length;\n var max = 0;\n for (var i = 0; i < 1 << n; i++)\n {\n var count = 0;\n var set = new HashSet<int>();\n for (var j = 0; j < n; j++)\n {\n ... | 1 | 0 | ['Bit Manipulation'] | 0 |
maximum-rows-covered-by-columns | c++ solution using bitmasking | c-solution-using-bitmasking-by-dilipsuth-vh0t | \nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) \n {\n int n=mat.size();\n int m=mat[0].size();\n i | dilipsuthar17 | NORMAL | 2022-09-03T16:12:35.365473+00:00 | 2022-09-03T16:12:35.365518+00:00 | 45 | false | ```\nclass Solution {\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) \n {\n int n=mat.size();\n int m=mat[0].size();\n int val=0;\n for(int i=0;i<(1<<m);i++)\n {\n if(__builtin_popcount(i)==cols)\n {\n int cov=0;\n ... | 1 | 0 | ['Bitmask', 'C++'] | 0 |
maximum-rows-covered-by-columns | Brute Force + Bitmasking | brute-force-bitmasking-by-placementtohmi-gcsx | \nclass Solution {\n\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n \n int mx = 0;\n \n for(int mask=0,cur = 0; | placementTohMilneSeRaha | NORMAL | 2022-09-03T16:06:50.473817+00:00 | 2022-09-03T16:10:56.350596+00:00 | 63 | false | ```\nclass Solution {\n\npublic:\n int maximumRows(vector<vector<int>>& mat, int cols) {\n \n int mx = 0;\n \n for(int mask=0,cur = 0;mask<(1ll<<(mat[0].size()+1));mask++)\n {\n\t\t\t\tif(__builtin_popcount(mask) > cols) // basically checking if no of chosen \n\t\t\t\t\tcontinue; ... | 1 | 0 | ['C', 'Bitmask'] | 0 |
maximum-rows-covered-by-columns | Brute - Backtracking [C++] | brute-backtracking-c-by-hehehiiiiuuhuu-0sbe | \nclass Solution {\npublic:\n int ans = 0;\n \n int countRow(vector<int>&temp,vector<vector<int>>&mat)\n {\n int cnt = 0;\n unordered_ | hehehiiiiuuhuu | NORMAL | 2022-09-03T16:04:44.564837+00:00 | 2022-09-03T16:04:44.564889+00:00 | 59 | false | ```\nclass Solution {\npublic:\n int ans = 0;\n \n int countRow(vector<int>&temp,vector<vector<int>>&mat)\n {\n int cnt = 0;\n unordered_map<int,int>mpp;\n for(auto x:temp)mpp[x]++;\n \n for(auto row : mat)\n {\n bool flag = true;\n for(int i=0... | 1 | 0 | ['Backtracking', 'C'] | 1 |
maximum-rows-covered-by-columns | [Python3] enumeration | python3-enumeration-by-ye15-ba2g | Please pull this commit for solutions of biweekly 86. \n\n\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n m, n = | ye15 | NORMAL | 2022-09-03T16:03:09.186205+00:00 | 2022-09-03T18:11:15.709226+00:00 | 129 | false | Please pull this [commit](https://github.com/gaosanyong/leetcode/commit/35b262c16bc702edbad6adc895bc8321a037ebaa) for solutions of biweekly 86. \n\n```\nclass Solution:\n def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n m, n = len(mat), len(mat[0])\n masks = []\n for i in range(m... | 1 | 0 | ['Python3'] | 1 |
maximum-rows-covered-by-columns | C++ Brute force using recursion backtracking | c-brute-force-using-recursion-backtracki-vfzl | \nclass Solution {\npublic:\n int maxi = 0;\n vector<int>v;\n \n void count(vector<vector<int>>&mat){\n int c = 0;\n for(int i = 0;i<m | mohitdbst | NORMAL | 2022-09-03T16:03:06.779073+00:00 | 2022-09-03T16:03:06.779121+00:00 | 154 | false | ```\nclass Solution {\npublic:\n int maxi = 0;\n vector<int>v;\n \n void count(vector<vector<int>>&mat){\n int c = 0;\n for(int i = 0;i<mat.size();i++){\n int t = 0;\n int co= 0 ;\n for(int j = 0;j<mat[i].size();j++){\n if(mat[i][j] == 1)t++;\n ... | 1 | 0 | ['Backtracking', 'Recursion', 'C'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.