TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 2737,3 "name": "row_with_maximum_ones",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/row-with-maximum-ones/",6 "date": "1680998400000",7 "task_description": "Given a `m x n` binary matrix `mat`, find the **0-indexed** position of the row that contains the **maximum** count of **ones,** and the number of ones in that row. In case there are multiple rows that have the maximum count of ones, the row with the **smallest row number** should be selected. Return_ an array containing the index of the row, and the number of ones in it._ **Example 1:** ``` **Input:** mat = [[0,1],[1,0]] **Output:** [0,1] **Explanation:** Both rows have the same number of 1's. So we return the index of the smaller row, 0, and the maximum count of ones (1`)`. So, the answer is [0,1]. ``` **Example 2:** ``` **Input:** mat = [[0,0,0],[0,1,1]] **Output:** [1,2] **Explanation:** The row indexed 1 has the maximum count of ones `(2)`. So we return its index, `1`, and the count. So, the answer is [1,2]. ``` **Example 3:** ``` **Input:** mat = [[0,0],[1,1],[0,0]] **Output:** [1,2] **Explanation:** The row indexed 1 has the maximum count of ones (2). So the answer is [1,2]. ``` **Constraints:** `m == mat.length` `n == mat[i].length` `1 <= m, n <= 100` `mat[i][j]` is either `0` or `1`.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "mat = [[0,1],[1,0]]",12 "output": "[0,1] "13 },14 {15 "label": "Example 2",16 "input": "mat = [[0,0,0],[0,1,1]]",17 "output": "[1,2] "18 },19 {20 "label": "Example 3",21 "input": "mat = [[0,0],[1,1],[0,0]]",22 "output": "[1,2] "23 }24 ],25 "private_test_cases": [26 {27 "input": [28 [29 1,30 0,31 1,32 1,33 1,34 0,35 1,36 0,37 1,38 0,39 1,40 1,41 1,42 0,43 1,44 0,45 0,46 1,47 0,48 0,49 1,50 1,51 1,52 0,53 1,54 0,55 1,56 1,57 1,58 0,59 1,60 0,61 1,62 0,63 1,64 0,65 1,66 0,67 0,68 0,69 1,70 1,71 0,72 1,73 1,74 1,75 1,76 0,77 0,78 1,79 1,80 0,81 182 ],83 [84 1,85 1,86 0,87 0,88 0,89 0,90 0,91 0,92 1,93 0,94 0,95 0,96 1,97 0,98 1,99 0,100 0,101 1,102 0,103 0,104 0,105 0,106 1,107 1,108 1,109 1,110 0,111 0,112 0,113 1,114 1,115 0,116 1,117 1,118 0,119 1,120 0,121 1,122 0,123 0,124 0,125 0,126 0,127 1,128 1,129 1,130 0,131 1,132 1,133 1,134 0,135 1,136 0137 ],138 [139 1,140 0,141 0,142 0,143 1,144 0,145 0,146 1,147 1,148 1,149 1,150 0,151 0,152 1,153 0,154 1,155 0,156 0,157 0,158 0,159 1,160 1,161 0,162 0,163 1,164 0,165 1,166 0,167 1,168 1,169 0,170 1,171 1,172 0,173 0,174 0,175 1,176 0,177 0,178 0,179 0,180 1,181 0,182 1,183 1,184 1,185 1,186 1,187 1,188 0,189 0,190 0,191 0192 ],193 [194 0,195 0,196 0,197 0,198 1,199 1,200 1,201 1,202 0,203 1,204 0,205 1,206 1,207 0,208 1,209 0,210 1,211 0,212 1,213 1,214 1,215 1,216 1,217 1,218 0,219 0,220 1,221 0,222 0,223 1,224 0,225 0,226 1,227 1,228 1,229 0,230 1,231 0,232 0,233 1,234 1,235 1,236 0,237 1,238 0,239 1,240 1,241 1,242 1,243 1,244 0,245 1,246 0247 ],248 [249 0,250 1,251 1,252 1,253 1,254 1,255 0,256 0,257 1,258 0,259 1,260 0,261 0,262 1,263 0,264 1,265 1,266 1,267 1,268 0,269 0,270 1,271 1,272 1,273 1,274 0,275 0,276 1,277 0,278 1,279 1,280 1,281 0,282 1,283 0,284 0,285 0,286 1,287 0,288 1,289 0,290 0,291 0,292 0,293 1,294 0,295 1,296 0,297 0,298 1,299 1,300 1,301 0302 ],303 [304 0,305 1,306 1,307 1,308 1,309 1,310 1,311 0,312 0,313 1,314 1,315 1,316 0,317 1,318 1,319 0,320 0,321 1,322 1,323 1,324 0,325 0,326 1,327 1,328 0,329 0,330 0,331 0,332 0,333 0,334 0,335 0,336 0,337 1,338 1,339 1,340 1,341 1,342 1,343 0,344 0,345 1,346 0,347 1,348 0,349 1,350 0,351 1,352 1,353 1,354 1,355 0,356 1357 ],358 [359 0,360 1,361 1,362 1,363 0,364 0,365 1,366 1,367 1,368 1,369 1,370 0,371 0,372 0,373 1,374 0,375 0,376 1,377 0,378 1,379 0,380 1,381 0,382 1,383 0,384 1,385 0,386 0,387 1,388 0,389 0,390 0,391 0,392 0,393 1,394 1,395 1,396 1,397 0,398 0,399 1,400 0,401 1,402 1,403 1,404 1,405 0,406 0,407 1,408 0,409 1,410 1,411 1412 ],413 [414 1,415 0,416 0,417 0,418 1,419 1,420 1,421 0,422 0,423 1,424 0,425 0,426 1,427 1,428 0,429 1,430 1,431 0,432 1,433 0,434 1,435 1,436 1,437 0,438 0,439 1,440 0,441 1,442 1,443 0,444 0,445 0,446 0,447 1,448 1,449 1,450 0,451 0,452 1,453 0,454 0,455 1,456 1,457 0,458 1,459 1,460 1,461 1,462 0,463 0,464 0,465 1,466 1467 ],468 [469 1,470 1,471 1,472 0,473 1,474 1,475 0,476 1,477 1,478 0,479 1,480 1,481 0,482 1,483 1,484 0,485 0,486 0,487 1,488 0,489 1,490 1,491 0,492 1,493 1,494 0,495 0,496 0,497 0,498 1,499 1,500 1,501 1,502 0,503 1,504 1,505 0,506 1,507 0,508 0,509 0,510 1,511 0,512 1,513 0,514 0,515 1,516 0,517 1,518 0,519 1,520 1,521 1522 ],523 [524 0,525 1,526 1,527 1,528 1,529 1,530 0,531 1,532 1,533 1,534 1,535 0,536 1,537 0,538 1,539 0,540 1,541 0,542 1,543 1,544 0,545 0,546 0,547 0,548 0,549 1,550 0,551 0,552 1,553 1,554 1,555 0,556 1,557 0,558 0,559 1,560 1,561 0,562 0,563 0,564 0,565 0,566 1,567 0,568 1,569 0,570 1,571 0,572 1,573 0,574 0,575 1,576 1577 ],578 [579 0,580 0,581 0,582 1,583 1,584 0,585 0,586 1,587 0,588 0,589 1,590 0,591 0,592 1,593 0,594 0,595 1,596 0,597 0,598 0,599 0,600 0,601 1,602 1,603 1,604 1,605 1,606 0,607 0,608 1,609 1,610 0,611 0,612 0,613 1,614 1,615 0,616 0,617 0,618 0,619 0,620 0,621 0,622 0,623 1,624 1,625 1,626 1,627 0,628 0,629 1,630 0,631 0632 ],633 [634 1,635 1,636 1,637 1,638 1,639 0,640 1,641 0,642 1,643 0,644 1,645 0,646 0,647 1,648 0,649 1,650 1,651 1,652 1,653 1,654 1,655 0,656 1,657 0,658 0,659 0,660 0,661 0,662 0,663 1,664 1,665 0,666 1,667 1,668 0,669 1,670 1,671 0,672 1,673 1,674 1,675 0,676 1,677 1,678 1,679 1,680 0,681 0,682 1,683 1,684 1,685 1,686 1687 ],688 [689 0,690 0,691 0,692 0,693 1,694 0,695 0,696 1,697 1,698 0,699 0,700 1,701 0,702 0,703 0,704 1,705 1,706 0,707 0,708 1,709 0,710 0,711 1,712 1,713 1,714 0,715 1,716 0,717 1,718 1,719 1,720 0,721 0,722 0,723 0,724 0,725 1,726 1,727 1,728 1,729 0,730 0,731 1,732 0,733 0,734 0,735 1,736 1,737 1,738 1,739 0,740 1,741 0742 ],743 [744 1,745 1,746 1,747 0,748 0,749 0,750 0,751 1,752 0,753 0,754 0,755 1,756 0,757 0,758 0,759 0,760 0,761 1,762 0,763 0,764 0,765 1,766 1,767 1,768 1,769 1,770 0,771 1,772 1,773 1,774 0,775 1,776 0,777 1,778 0,779 0,780 1,781 1,782 1,783 0,784 0,785 1,786 1,787 0,788 0,789 1,790 0,791 0,792 1,793 1,794 0,795 0,796 0797 ],798 [799 1,800 0,801 0,802 1,803 1,804 1,805 0,806 1,807 1,808 1,809 0,810 0,811 1,812 1,813 1,814 1,815 1,816 1,817 1,818 0,819 1,820 0,821 1,822 1,823 1,824 0,825 0,826 0,827 1,828 0,829 0,830 0,831 0,832 1,833 1,834 0,835 0,836 0,837 0,838 1,839 1,840 0,841 0,842 0,843 1,844 1,845 0,846 1,847 1,848 0,849 1,850 0,851 1852 ],853 [854 0,855 1,856 0,857 0,858 1,859 0,860 1,861 1,862 1,863 0,864 1,865 1,866 0,867 1,868 1,869 0,870 0,871 0,872 1,873 1,874 0,875 0,876 0,877 0,878 0,879 0,880 0,881 0,882 0,883 1,884 1,885 1,886 1,887 0,888 1,889 0,890 1,891 0,892 0,893 0,894 0,895 1,896 0,897 1,898 0,899 1,900 0,901 1,902 1,903 0,904 1,905 1,906 1907 ],908 [909 1,910 0,911 1,912 1,913 1,914 1,915 1,916 0,917 1,918 1,919 0,920 0,921 1,922 0,923 1,924 1,925 0,926 0,927 0,928 0,929 1,930 0,931 1,932 0,933 1,934 0,935 0,936 1,937 1,938 1,939 1,940 1,941 0,942 1,943 1,944 1,945 1,946 0,947 0,948 1,949 1,950 0,951 0,952 1,953 1,954 1,955 1,956 0,957 1,958 0,959 0,960 1,961 1962 ],963 [964 1,965 0,966 1,967 1,968 0,969 1,970 1,971 0,972 0,973 1,974 1,975 0,976 0,977 1,978 1,979 0,980 0,981 1,982 1,983 0,984 0,985 0,986 0,987 1,988 0,989 1,990 0,991 1,992 1,993 1,994 1,995 1,996 1,997 1,998 0,999 0,1000 1,1001 0,1002 0,1003 0,1004 0,1005 1,1006 1,1007 1,1008 0,1009 1,1010 0,1011 1,1012 1,1013 1,1014 1,1015 0,1016 11017 ],1018 [1019 1,1020 1,1021 1,1022 0,1023 0,1024 1,1025 1,1026 0,1027 1,1028 0,1029 1,1030 0,1031 0,1032 0,1033 0,1034 0,1035 0,1036 0,1037 1,1038 0,1039 1,1040 0,1041 0,1042 1,1043 0,1044 0,1045 0,1046 0,1047 0,1048 0,1049 1,1050 1,1051 0,1052 1,1053 1,1054 1,1055 1,1056 1,1057 1,1058 1,1059 1,1060 0,1061 1,1062 0,1063 1,1064 1,1065 1,1066 0,1067 0,1068 1,1069 1,1070 0,1071 01072 ],1073 [1074 0,1075 0,1076 1,1077 0,1078 0,1079 0,1080 0,1081 0,1082 1,1083 1,1084 1,1085 0,1086 1,1087 1,1088 1,1089 1,1090 0,1091 0,1092 1,1093 1,1094 0,1095 1,1096 0,1097 0,1098 0,1099 0,1100 1,1101 0,1102 1,1103 0,1104 0,1105 0,1106 1,1107 1,1108 1,1109 0,1110 1,1111 0,1112 1,1113 1,1114 1,1115 0,1116 1,1117 0,1118 0,1119 1,1120 1,1121 1,1122 0,1123 0,1124 0,1125 0,1126 01127 ],1128 [1129 0,1130 0,1131 0,1132 0,1133 0,1134 0,1135 1,1136 1,1137 1,1138 1,1139 0,1140 0,1141 1,1142 1,1143 1,1144 0,1145 1,1146 1,1147 0,1148 0,1149 0,1150 0,1151 0,1152 1,1153 1,1154 1,1155 1,1156 0,1157 0,1158 0,1159 1,1160 0,1161 1,1162 0,1163 0,1164 1,1165 0,1166 1,1167 1,1168 0,1169 1,1170 1,1171 0,1172 1,1173 0,1174 0,1175 1,1176 1,1177 1,1178 0,1179 1,1180 1,1181 01182 ],1183 [1184 1,1185 1,1186 1,1187 0,1188 0,1189 0,1190 1,1191 0,1192 1,1193 1,1194 0,1195 0,1196 1,1197 0,1198 1,1199 1,1200 1,