FPEvalDataset/LeetCodeProblem
0305
1{2 "id": 2826,3 "name": "find_a_good_subset_of_the_matrix",4 "difficulty": "Hard",5 "link": "https://leetcode.com/problems/find-a-good-subset-of-the-matrix/",6 "date": "2023-05-27 00:00:00",7 "task_description": "You are given a **0-indexed** `m x n` binary matrix `grid`. Let us call a **non-empty** subset of rows **good** if the sum of each column of the subset is at most half of the length of the subset. More formally, if the length of the chosen subset of rows is `k`, then the sum of each column should be at most `floor(k / 2)`. Return _an integer array that contains row indices of a good subset sorted in **ascending** order._ If there are multiple good subsets, you can return any of them. If there are no good subsets, return an empty array. A **subset** of rows of the matrix `grid` is any matrix that can be obtained by deleting some (possibly none or all) rows from `grid`. **Example 1:** ``` **Input:** grid = [[0,1,1,0],[0,0,0,1],[1,1,1,1]] **Output:** [0,1] **Explanation:** We can choose the 0th and 1st rows to create a good subset of rows. The length of the chosen subset is 2. - The sum of the 0th column is 0 + 0 = 0, which is at most half of the length of the subset. - The sum of the 1st column is 1 + 0 = 1, which is at most half of the length of the subset. - The sum of the 2nd column is 1 + 0 = 1, which is at most half of the length of the subset. - The sum of the 3rd column is 0 + 1 = 1, which is at most half of the length of the subset. ``` **Example 2:** ``` **Input:** grid = [[0]] **Output:** [0] **Explanation:** We can choose the 0th row to create a good subset of rows. The length of the chosen subset is 1. - The sum of the 0th column is 0, which is at most half of the length of the subset. ``` **Example 3:** ``` **Input:** grid = [[1,1,1],[1,1,1]] **Output:** [] **Explanation:** It is impossible to choose any subset of rows to create a good subset. ``` **Constraints:** `m == grid.length` `n == grid[i].length` `1 <= m <= 104` `1 <= n <= 5` `grid[i][j]` is either `0` or `1`.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "grid = [[0,1,1,0],[0,0,0,1],[1,1,1,1]]",12 "output": "[0,1] "13 },14 {15 "label": "Example 2",16 "input": "grid = [[0]]",17 "output": "[0] "18 },19 {20 "label": "Example 3",21 "input": "grid = [[1,1,1],[1,1,1]]",22 "output": "[] "23 }24 ],25 "private_test_cases": [26 {27 "input": [28 [29 130 ]31 ],32 "output": []33 },34 {35 "input": [36 [37 0,38 1,39 040 ],41 [42 0,43 0,44 145 ],46 [47 0,48 1,49 050 ]51 ],52 "output": [53 0,54 155 ]56 },57 {58 "input": [59 [60 1,61 1,62 1,63 1,64 165 ],66 [67 0,68 0,69 0,70 0,71 172 ],73 [74 0,75 1,76 1,77 0,78 179 ],80 [81 1,82 0,83 0,84 1,85 086 ],87 [88 1,89 1,90 1,91 0,92 093 ]94 ],95 "output": [96 1,97 398 ]99 },100 {101 "input": [102 [103 0,104 0,105 1,106 1,107 1108 ],109 [110 0,111 0,112 0,113 1,114 1115 ],116 [117 1,118 0,119 1,120 0,121 1122 ],123 [124 0,125 1,126 1,127 0,128 1129 ],130 [131 0,132 1,133 0,134 0,135 0136 ],137 [138 1,139 1,140 0,141 0,142 0143 ],144 [145 0,146 1,147 0,148 0,149 0150 ],151 [152 1,153 0,154 1,155 1,156 1157 ],158 [159 0,160 0,161 0,162 1,163 0164 ],165 [166 1,167 1,168 0,169 1,170 1171 ]172 ],173 "output": [174 0,175 4176 ]177 },178 {179 "input": [180 [181 1,182 1,183 1,184 1,185 0186 ],187 [188 1,189 1,190 1,191 1,192 1193 ],194 [195 1,196 1,197 1,198 1,199 1200 ],201 [202 1,203 1,204 1,205 0,206 1207 ],208 [209 0,210 0,211 0,212 0,213 0214 ],215 [216 1,217 1,218 0,219 1,220 1221 ],222 [223 1,224 0,225 0,226 0,227 1228 ],229 [230 0,231 0,232 0,233 0,234 1235 ],236 [237 1,238 1,239 0,240 0,241 0242 ],243 [244 0,245 1,246 1,247 0,248 0249 ],250 [251 1,252 1,253 1,254 0,255 1256 ],257 [258 0,259 1,260 1,261 0,262 1263 ],264 [265 1,266 1,267 0,268 0,269 0270 ],271 [272 0,273 1,274 0,275 1,276 1277 ],278 [279 1,280 0,281 0,282 0,283 1284 ],285 [286 1,287 0,288 0,289 0,290 0291 ],292 [293 0,294 1,295 1,296 0,297 1298 ],299 [300 0,301 1,302 0,303 0,304 0305 ],306 [307 1,308 0,309 1,310 0,311 0312 ],313 [314 1,315 0,316 1,317 0,318 0319 ],320 [321 0,322 0,323 0,324 1,325 1326 ],327 [328 0,329 1,330 0,331 1,332 1333 ],334 [335 0,336 0,337 1,338 1,339 0340 ],341 [342 1,343 0,344 1,345 1,346 0347 ],348 [349 0,350 1,351 1,352 1,353 0354 ],355 [356 1,357 1,358 0,359 1,360 0361 ],362 [363 1,364 1,365 0,366 0,367 0368 ],369 [370 0,371 0,372 1,373 0,374 0375 ],376 [377 0,378 0,379 1,380 0,381 1382 ],383 [384 0,385 0,386 0,387 0,388 0389 ],390 [391 0,392 1,393 0,394 1,395 1396 ],397 [398 0,399 1,400 1,401 1,402 1403 ],404 [405 1,406 1,407 1,408 0,409 1410 ],411 [412 1,413 0,414 0,415 1,416 1417 ],418 [419 0,420 1,421 1,422 0,423 0424 ],425 [426 1,427 0,428 1,429 1,430 1431 ],432 [433 0,434 1,435 0,436 0,437 1438 ],439 [440 0,441 1,442 0,443 1,444 0445 ],446 [447 1,448 0,449 1,450 1,451 1452 ],453 [454 0,455 1,456 0,457 1,458 1459 ],460 [461 1,462 0,463 1,464 1,465 1466 ],467 [468 1,469 0,470 1,471 1,472 1473 ],474 [475 1,476 1,477 0,478 0,479 0480 ],481 [482 0,483 1,484 1,485 0,486 0487 ],488 [489 1,490 1,491 0,492 0,493 0494 ],495 [496 0,497 0,498 0,499 0,500 0501 ],502 [503 0,504 1,505 0,506 0,507 1508 ],509 [510 1,511 0,512 1,513 1,514 0515 ],516 [517 0,518 0,519 0,520 1,521 1522 ],523 [524 0,525 0,526 1,527 0,528 0529 ],530 [531 0,532 1,533 0,534 1,535 0536 ],537 [538 1,539 0,540 1,541 0,542 1543 ],544 [545 0,546 1,547 1,548 0,549 1550 ],551 [552 1,553 1,554 1,555 1,556 1557 ],558 [559 1,560 1,561 1,562 0,563 1564 ],565 [566 1,567 0,568 1,569 0,570 1571 ],572 [573 0,574 1,575 1,576 0,577 0578 ],579 [580 0,581 1,582 1,583 1,584 0585 ],586 [587 0,588 1,589 1,590 0,591 0592 ],593 [594 0,595 1,596 0,597 0,598 1599 ],600 [601 1,602 1,603 1,604 0,605 1606 ],607 [608 1,609 0,610 0,611 0,612 1613 ],614 [615 1,616 1,617 0,618 1,619 1620 ],621 [622 0,623 0,624 0,625 1,626 1627 ],628 [629 0,630 0,631 1,632 0,633 0634 ],635 [636 0,637 0,638 0,639 0,640 0641 ],642 [643 1,644 0,645 0,646 1,647 1648 ],649 [650 1,651 0,652 1,653 0,654 0655 ],656 [657 1,658 0,659 0,660 1,661 0662 ],663 [664 1,665 1,666 0,667 0,668 1669 ],670 [671 1,672 1,673 0,674 1,675 0676 ],677 [678 0,679 0,680 0,681 1,682 0683 ],684 [685 1,686 0,687 0,688 0,689 0690 ],691 [692 1,693 0,694 1,695 1,696 0697 ],698 [699 0,700 0,701 0,702 1,703 0704 ],705 [706 0,707 1,708 0,709 0,710 0711 ],712 [713 1,714 1,715 0,716 0,717 0718 ],719 [720 1,721 0,722 1,723 0,724 1725 ],726 [727 0,728 1,729 0,730 0,731 1732 ],733 [734 1,735 1,736 0,737 0,738 1739 ],740 [741 0,742 1,743 1,744 1,745 1746 ],747 [748 0,749 1,750 1,751 0,752 1753 ],754 [755 0,756 0,757 0,758 1,759 1760 ],761 [762 0,763 0,764 0,765 0,766 0767 ],768 [769 0,770 0,771 0,772 1,773 0774 ],775 [776 1,777 1,778 0,779 1,780 0781 ],782 [783 1,784 1,785 0,786 0,787 1788 ],789 [790 1,791 0,792 0,793 1,794 0795 ],796 [797 0,798 0,799 1,800 0,801 1802 ],803 [804 1,805 0,806 0,807 1,808 0809 ],810 [811 0,812 1,813 1,814 0,815 1816 ],817 [818 0,819 1,820 1,821 0,822 0823 ],824 [825 0,826 0,827 1,828 1,829 0830 ],831 [832 0,833 1,834 0,835 1,836 0837 ],838 [839 0,840 1,841 0,842 1,843 0844 ],845 [846 1,847 0,848 1,849 0,850 1851 ],852 [853 0,854 1,855 0,856 0,857 1858 ],859 [860 1,861 1,862 1,863 1,864 1865 ],866 [867 0,868 0,869 0,870 0,871 0872 ],873 [874 1,875 0,876 0,877 0,878 0879 ],880 [881 0,882 1,883 0,884 1,885 1886 ],887 [888 1,889 1,890 1,891 1,892 0893 ],894 [895 0,896 1,897 1,898 1,899 0900 ],901 [902 1,903 0,904 0,905 1,906 1907 ],908 [909 1,910 1,911 0,912 1,913 1914 ],915 [916 1,917 0,918 0,919 0,920 0921 ],922 [923 0,924 0,925 0,926 0,927 1928 ],929 [930 0,931 0,932 1,933 1,934 1935 ],936 [937 1,938 1,939 1,940 1,941 0942 ],943 [944 0,945 1,946 0,947 1,948 1949 ],950 [951 1,952 1,953 0,954 0,955 1956 ],957 [958 0,959 1,960 1,961 1,962 0963 ],964 [965 1,966 0,967 1,968 1,969 0970 ],971 [972 0,973 0,974 1,975 1,976 1977 ],978 [979 1,980 1,981 0,982 1,983 1984 ],985 [986 1,987 1,988 0,989 0,990 1991 ],992 [993 0,994 1,995 1,996 0,997 0998 ],999 [1000 0,1001 0,1002 0,1003 1,1004 11005 ],1006 [1007 1,1008 1,1009 1,1010 0,1011 11012 ],1013 [1014 1,1015 0,1016 1,1017 0,1018 01019 ],1020 [1021 0,1022 0,1023 1,1024 0,1025 11026 ],1027 [1028 0,1029 0,1030 1,1031 1,1032 01033 ],1034 [1035 1,1036 0,1037 0,1038 1,1039 11040 ],1041 [1042 1,1043 0,1044 0,1045 0,1046 01047 ],1048 [1049 0,1050 0,1051 0,1052 1,1053 11054 ],1055 [1056 1,1057 0,1058 0,1059 1,1060 11061 ],1062 [1063 0,1064 1,1065 1,1066 1,1067 01068 ],1069 [1070 0,1071 0,1072 0,1073 0,1074 01075 ],1076 [1077 1,1078 0,1079 1,1080 0,1081 01082 ],1083 [1084 1,1085 0,1086 0,1087 0,1088 11089 ],1090 [1091 1,1092 1,1093 0,1094 0,1095 01096 ],1097 [1098 1,1099 0,1100 1,1101 0,1102 11103 ],1104 [1105 0,1106 0,1107 0,1108 0,1109 01110 ],1111 [1112 0,1113 1,1114 1,1115 0,1116 01117 ],1118 [1119 1,1120 0,1121 1,1122 0,1123 11124 ],1125 [1126 1,1127 1,1128 1,1129 1,1130 11131 ],1132 [1133 0,1134 0,1135 1,1136 1,1137 01138 ],1139 [1140 0,1141 0,1142 1,1143 1,1144 11145 ],1146 [1147 1,1148 1,1149 0,1150 1,1151 11152 ],1153 [1154 0,1155 1,1156 1,1157 0,1158 11159 ],1160 [1161 0,1162 1,1163 0,1164 0,1165 01166 ],1167 [1168 1,1169 0,1170 1,1171 1,1172 01173 ],1174 [1175 1,1176 1,1177 1,1178 1,1179 01180 ],1181 [1182 1,1183 0,1184 0,1185 0,1186 11187 ],1188 [1189 0,1190 1,1191 0,1192 0,1193 01194 ],1195 [1196 1,1197 0,1198 0,1199 0,1200 0