FPEvalDataset/LeetCodeProblem
0305
1{2 "id": 2498,3 "name": "smallest_subarrays_with_maximum_bitwise_or",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/smallest-subarrays-with-maximum-bitwise-or/",6 "date": "1662163200000",7 "task_description": "You are given a **0-indexed** array `nums` of length `n`, consisting of non-negative integers. For each index `i` from `0` to `n - 1`, you must determine the size of the **minimum sized** non-empty subarray of `nums` starting at `i` (**inclusive**) that has the **maximum** possible **bitwise OR**. In other words, let `Bij` be the bitwise OR of the subarray `nums[i...j]`. You need to find the smallest subarray starting at `i`, such that bitwise OR of this subarray is equal to `max(Bik)` where `i <= k <= n - 1`. The bitwise OR of an array is the bitwise OR of all the numbers in it. Return _an integer array _`answer`_ of size _`n`_ where _`answer[i]`_ is the length of the **minimum** sized subarray starting at _`i`_ with **maximum** bitwise OR._ A **subarray** is a contiguous non-empty sequence of elements within an array. **Example 1:** ``` **Input:** nums = [1,0,2,1,3] **Output:** [3,3,2,2,1] **Explanation:** The maximum possible bitwise OR starting at any index is 3. - Starting at index 0, the shortest subarray that yields it is [1,0,2]. - Starting at index 1, the shortest subarray that yields the maximum bitwise OR is [0,2,1]. - Starting at index 2, the shortest subarray that yields the maximum bitwise OR is [2,1]. - Starting at index 3, the shortest subarray that yields the maximum bitwise OR is [1,3]. - Starting at index 4, the shortest subarray that yields the maximum bitwise OR is [3]. Therefore, we return [3,3,2,2,1]. ``` **Example 2:** ``` **Input:** nums = [1,2] **Output:** [2,1] **Explanation: **Starting at index 0, the shortest subarray that yields the maximum bitwise OR is of length 2. Starting at index 1, the shortest subarray that yields the maximum bitwise OR is of length 1. Therefore, we return [2,1]. ``` **Constraints:** `n == nums.length` `1 <= n <= 105` `0 <= nums[i] <= 109`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [1,0,2,1,3]",12 "output": "[3,3,2,2,1] "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,2]",17 "output": "[2,1] "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 2,24 6,25 10,26 6,27 1,28 6,29 5,30 631 ],32 "output": [33 5,34 4,35 3,36 2,37 2,38 2,39 2,40 141 ]42 },43 {44 "input": [45 19,46 7,47 9,48 38,49 83,50 13,51 19,52 14,53 97,54 0,55 44,56 79,57 44,58 76,59 3,60 21,61 87,62 5,63 92,64 51,65 93,66 77,67 20,68 70,69 74,70 28,71 36,72 27,73 23,74 64,75 87,76 20,77 56,78 54,79 55,80 8,81 34,82 67,83 59,84 8885 ],86 "output": [87 5,88 4,89 3,90 3,91 5,92 4,93 3,94 9,95 8,96 7,97 6,98 5,99 4,100 7,101 6,102 5,103 4,104 3,105 2,106 2,107 7,108 6,109 6,110 5,111 4,112 5,113 4,114 6,115 5,116 4,117 3,118 7,119 6,120 5,121 4,122 4,123 3,124 2,125 2,126 1127 ]128 },129 {130 "input": [131 399,132 741,133 898,134 831,135 528,136 737,137 725,138 742,139 993,140 450,141 918,142 153,143 217,144 602,145 374,146 458,147 386,148 319,149 640,150 667,151 979,152 19,153 133,154 430,155 660,156 846,157 164,158 168,159 135,160 622,161 10,162 186,163 656,164 911,165 742,166 517,167 552,168 280,169 843,170 278,171 267,172 148,173 714,174 325,175 427,176 349,177 212,178 499,179 249,180 931,181 550,182 842,183 545,184 495,185 16,186 992,187 908,188 721,189 653,190 862,191 760,192 705,193 799,194 981,195 887,196 660,197 435,198 934,199 941,200 437,201 582,202 396,203 334,204 576,205 500,206 659,207 794,208 69209 ],210 "output": [211 4,212 3,213 4,214 3,215 8,216 7,217 6,218 5,219 4,220 6,221 5,222 4,223 3,224 5,225 5,226 4,227 5,228 4,229 6,230 5,231 4,232 5,233 4,234 6,235 5,236 7,237 8,238 7,239 6,240 5,241 5,242 4,243 3,244 5,245 4,246 7,247 6,248 8,249 7,250 6,251 5,252 4,253 4,254 7,255 6,256 5,257 4,258 4,259 3,260 6,261 5,262 4,263 3,264 3,265 6,266 5,267 5,268 4,269 3,270 3,271 3,272 4,273 3,274 6,275 5,276 6,277 5,278 4,279 3,280 3,281 6,282 5,283 4,284 4,285 3,286 3,287 2,288 1289 ]290 },291 {292 "input": [293 4440,294 6125,295 209,296 142,297 7210,298 7415,299 2500,300 5399,301 4462,302 4819,303 1413,304 6006,305 8712,306 9169,307 7768,308 5980,309 5748,310 2848,311 2673,312 7102,313 2386,314 803,315 3281,316 6796,317 7809,318 7000,319 695,320 9857,321 9874,322 7098,323 4813,324 4015,325 9567,326 6940,327 8267,328 8373,329 3362,330 7252,331 1140,332 590,333 2694,334 2372,335 7952,336 9660,337 6923,338 4748,339 7889,340 4687,341 678,342 1528,343 4737,344 7402,345 6423,346 2511,347 243,348 9257,349 7897,350 6,351 5484,352 5258,353 5762,354 2005,355 9878,356 6041,357 5506,358 5039,359 2309,360 3360,361 604,362 6226,363 6442,364 9758,365 4014,366 9481,367 1044,368 1086,369 8640,370 9112,371 8647,372 8528,373 8503,374 4261,375 5693,376 6260,377 8896,378 4386,379 7751,380 8969,381 6330,382 6622,383 4881,384 8900,385 8656,386 1504,387 497,388 4532,389 133,390 6378,391 9528,392 8546,393 3306,394 2599,395 7484,396 9352,397 692,398 333,399 7399,400 8482,401 9303,402 3441,403 6857,404 4502,405 5685,406 7460,407 2450,408 3320,409 2381,410 1456,411 5132,412 5671,413 1850,414 3427,415 5973,416 6642,417 8872,418 5078,419 6942,420 7655,421 2385,422 4136,423 1817,424 3209,425 9386,426 6061,427 3517,428 7575,429 7476,430 5106,431 6568,432 16,433 2482,434 6966,435 2667,436 4987,437 9035,438 2180,439 6500,440 7775,441 9570,442 4700,443 1946,444 3131,445 8537,446 4440,447 5622,448 1593,449 2973,450 5284,451 8869,452 6469,453 5033,454 4183,455 8404,456 1830,457 8503,458 8914,459 4421,460 6646,461 9955,462 8790,463 8137,464 4579,465 7666,466 7862,467 1510,468 7308,469 7603,470 79,471 9516,472 6435,473 9964,474 8299,475 7912,476 3538,477 4148,478 938,479 4277,480 2323,481 4347,482 128,483 6955,484 6013,485 2166,486 2169,487 8524,488 7945,489 7615,490 2930,491 72,492 3529,493 4745,494 596,495 4105,496 4012,497 2204,498 2096,499 6462,500 5146,501 7421,502 3413,503 9767,504 733,505 8675,506 7558,507 8116,508 4977,509 5944,510 3107,511 8612,512 4294,513 2906,514 3051,515 4140,516 3585,517 9839,518 7181,519 4972,520 4170,521 3024,522 4277,523 4137,524 9751,525 4229,526 2295,527 260,528 5940,529 3452,530 2294,531 7828,532 3759,533 2866,534 9451,535 1988,536 8067,537 6096,538 6894,539 6411,540 9064,541 7119,542 9072,543 3823,544 2246,545 1294,546 462,547 1894,548 4246,549 4312,550 3534,551 6394,552 5009,553 8539,554 734,555 5407,556 4480,557 6797,558 1519,559 2529,560 333,561 6351,562 6216,563 1524,564 3776,565 126,566 198,567 3494,568 1884,569 7352,570 2785,571 9112,572 174,573 88,574 6814,575 4513,576 9973,577 9016,578 3341,579 5749,580 8731,581 3850,582 5072,583 8043,584 3136,585 7823,586 7563,587 3549,588 6141,589 3036,590 6838,591 9345,592 6421,593 7638,594 6694,595 5882,596 7265,597 1728,598 6015,599 9101,600 9696,601 6587,602 3031,603 7399,604 1883,605 5160,606 614,607 2622,608 9804,609 3677,610 6352,611 5120,612 4860,613 9155,614 7919,615 5907,616 3,617 2181,618 5386,619 3952,620 8598,621 6629,622 7901,623 4533,624 5894,625 4220,626 4210,627 8050,628 5812,629 3514,630 9406,631 5989,632 9198,633 2652,634 2405,635 7271,636 708,637 7407,638 9792,639 2495,640 1456,641 7046,642 6326,643 5947,644 3522,645 6827,646 8174,647 9986,648 5536,649 2729,650 9944,651 4514,652 5589,653 9668,654 2333,655 3236,656 9128,657 1360,658 6467,659 6370,660 3777,661 7083,662 321,663 1811,664 4979,665 5858,666 2798,667 3828,668 9987,669 9500,670 134,671 2585,672 4538,673 7106,674 4249,675 9576,676 122,677 8907,678 4365,679 9098,680 1505,681 4002,682 1866,683 351,684 3430,685 2220,686 4201,687 1357,688 6915,689 1052,690 2306,691 5400,692 5620,693 4924,694 1136,695 4972,696 5725,697 5847,698 118,699 5283,700 8514,701 8243,702 2125,703 4355,704 5663,705 9415,706 8158,707 4046,708 7562,709 7937,710 150,711 2816,712 1128,713 5832,714 3918,715 7515,716 8690,717 494,718 6278,719 5471,720 2843,721 8812,722 5310,723 3561,724 7225,725 6405,726 4020,727 8394,728 8195,729 4615,730 4696,731 4804,732 3741,733 1117,734 1706,735 1272,736 6831,737 4261,738 6338,739 1922,740 6834,741 3524,742 7993,743 1283,744 151,745 913,746 4660,747 1799,748 6301,749 9555,750 222,751 4345,752 9585,753 8225,754 1989,755 9467,756 5713,757 3157,758 7074,759 8288,760 9958,761 2591,762 26,763 1365,764 2742,765 6466,766 4914,767 8015,768 8262,769 7000,770 2166,771 5427,772 2407,773 6465,774 7765,775 8669,776 5522,777 5977,778 8402,779 6576,780 6822,781 9457,782 9979,783 2111,784 1413,785 6883,786 4377,787 1573,788 6902,789 880,790 3929,791 784,792 3014,793 3431,794 3337,795 1367,796 7736,797 49,798 9883,799 7810,800 4709,801 9222,802 6074,803 6275,804 6225,805 4014,806 1936,807 9682,808 6873,809 3731,810 3944,811 497,812 6435,813 8170,814 1159,815 1531,816 3490,817 9689,818 3015,819 6420,820 8890,821 968,822 8828,823 107,824 6701,825 4359,826 4846,827 328,828 2475,829 300,830 7104,831 3239,832 8018,833 2898,834 7504,835 7846,836 6538,837 292,838 6149,839 9432,840 2993,841 5289,842 8922,843 9027,844 9152,845 8303,846 3058,847 3104,848 7428,849 1343,850 4421,851 5978,852 562,853 6972,854 1630,855 310,856 8609,857 1977,858 5718,859 1335,860 4063,861 2332,862 6348,863 6539,864 4016,865 3965,866 6258,867 2497,868 3025,869 2646,870 9463,871 4375,872 7678,873 9657,874 5730,875 4261,876 8360,877 7000,878 5953,879 480,880 5395,881 4561,882 8587,883 2196,884 6085,885 5122,886 9118,887 5916,888 1936,889 4033,890 2939,891 7013,892 3537,893 904,894 9447,895 1289,896 7282,897 2617,898 6758,899 6760,900 5361,901 8239,902 2514,903 8526,904 9452,905 9597,906 4394,907 9380,908 124,909 6971,910 8587,911 8222,912 7036,913 3332,914 9946,915 2173,916 7413,917 8952,918 3324,919 3908,920 6759,921 4683,922 6127,923 1702,924 8898,925 9981,926 8287,927 8152,928 2438,929 1924,930 6750,931 3006,932 8966,933 6161,934 2367,935 6193,936 490,937 6935,938 6037,939 4960,940 1677941 ],942 "output": [943 13,944 12,945 11,946 10,947 9,948 8,949 7,950 8,951 7,952 6,953 5,954 4,955 8,956 7,957 14,958 13,959 12,960 11,961 10,962 9,963 8,964 7,965 6,966 5,967 4,968 3,969 5,970 4,971 3,972 4,973 3,974 3,975 4,976 4,977 6,978 5,979 9,980 8,981 7,982 6,983 5,984 4,985 5,986 4,987 12,988 11,989 10,990 9,991 8,992 7,993 6,994 6,995 5,996 4,997 5,998 4,999 7,1000 10,1001 9,1002 8,1003 7,1004 6,1005 7,1006 9,1007 8,1008 7,1009 7,1010 7,1011 6,1012 5,1013 7,1014 11,1015 10,1016 11,1017 10,1018 9,1019 8,1020 7,1021 6,1022 5,1023 4,1024 5,1025 4,1026 5,1027 5,1028 4,1029 3,1030 7,1031 6,1032 5,1033 8,1034 7,1035 10,1036 9,1037 8,1038 7,1039 6,1040 5,1041 5,1042 4,1043 4,1044 5,1045 5,1046 4,1047 4,1048 6,1049 5,1050 4,1051 3,1052 16,1053 15,1054 14,1055 13,1056 12,1057 11,1058 10,1059 9,1060 8,1061 7,1062 6,1063 5,1064 4,1065 3,1066 5,1067 4,1068 8,1069 7,1070 6,1071 6,1072 9,1073 8,1074 7,1075 6,1076 12,1077 11,1078 10,1079 9,1080 11,1081 10,1082 9,1083 8,1084 7,1085 6,1086 5,1087 4,1088 4,1089 5,1090 4,1091 4,1092 4,1093 5,1094 5,1095 5,1096 6,1097 5,1098 7,1099 6,1100 5,1101 6,1102 5,1103 8,1104 10,1105 9,1106 8,1107 7,1108 6,1109 5,1110 4,1111 3,1112 3,1113 9,1114 8,1115 7,1116 6,1117 7,1118 6,1119 5,1120 7,1121 6,1122 5,1123 4,1124 4,1125 13,1126 12,1127 11,1128 10,1129 9,1130 8,1131 7,1132 6,1133 7,1134 6,1135 5,1136 4,1137 3,1138 16,1139 15,1140 14,1141 13,1142 12,1143 11,1144 10,1145 9,1146 8,1147 7,1148 6,1149 5,1150 4,1151 3,1152 5,1153 4,1154 3,1155 5,1156 6,1157 5,1158 4,1159 4,1160 4,1161 6,1162 6,1163 5,1164 8,1165 7,1166 6,1167 5,1168 7,1169 6,1170 5,1171 4,1172 6,1173 5,1174 6,1175 10,1176 9,1177 8,1178 7,1179 6,1180 5,1181 4,1182 5,1183 4,1184 4,1185 6,1186 5,1187 4,1188 6,1189 5,1190 4,1191 3,1192 7,1193 11,1194 10,1195 9,1196 8,1197 7,1198 6,1199 5,1200 4,