FPEvalDataset/LeetCodeProblem
0304
1{2 "id": 3790,3 "name": "fruits_into_baskets_ii",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/fruits-into-baskets-ii/",6 "date": "2025-03-02 00:00:00",7 "task_description": "You are given two arrays of integers, `fruits` and `baskets`, each of length `n`, where `fruits[i]` represents the **quantity** of the `ith` type of fruit, and `baskets[j]` represents the **capacity** of the `jth` basket. From left to right, place the fruits according to these rules: Each fruit type must be placed in the **leftmost available basket** with a capacity **greater than or equal** to the quantity of that fruit type. Each basket can hold only one type of fruit. If a fruit type cannot be placed in any basket, it remains unplaced. Return the number of fruit types that remain unplaced after all possible allocations are made. **Example 1:** **Input:** fruits = [4,2,5], baskets = [3,5,4] **Output:** 1 **Explanation:** `fruits[0] = 4` is placed in `baskets[1] = 5`. `fruits[1] = 2` is placed in `baskets[0] = 3`. `fruits[2] = 5` cannot be placed in `baskets[2] = 4`. Since one fruit type remains unplaced, we return 1. **Example 2:** **Input:** fruits = [3,6,1], baskets = [6,4,7] **Output:** 0 **Explanation:** `fruits[0] = 3` is placed in `baskets[0] = 6`. `fruits[1] = 6` cannot be placed in `baskets[1] = 4` (insufficient capacity) but can be placed in the next available basket, `baskets[2] = 7`. `fruits[2] = 1` is placed in `baskets[1] = 4`. Since all fruits are successfully placed, we return 0. **Constraints:** `n == fruits.length == baskets.length` `1 <= n <= 100` `1 <= fruits[i], baskets[i] <= 1000`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "fruits = [4,2,5], baskets = [3,5,4]",12 "output": "1 "13 },14 {15 "label": "Example 2",16 "input": "fruits = [3,6,1], baskets = [6,4,7]",17 "output": "0 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 [24 903,25 138,26 352,27 970,28 513,29 942,30 730,31 780,32 235,33 391,34 839,35 225,36 143,37 988,38 817,39 576,40 130,41 910,42 938,43 28,44 572,45 400,46 583,47 72,48 393,49 962,50 322,51 515,52 913,53 122,54 529,55 637,56 647,57 887,58 841,59 257,60 843,61 786,62 120,63 508,64 779,65 252,66 77,67 567,68 396,69 1000,70 151,71 639,72 634,73 641,74 479,75 222,76 975,77 309,78 652,79 283,80 328,81 980,82 28,83 596,84 73,85 753,86 785,87 598,88 64,89 435,90 627,91 603,92 119,93 408,94 795,95 183,96 76,97 83,98 274,99 354,100 789,101 660,102 664,103 9,104 349,105 774,106 592,107 654,108 723,109 282,110 741,111 946,112 420,113 53,114 950115 ],116 [117 602,118 189,119 806,120 622,121 620,122 991,123 466,124 388,125 135,126 605,127 166,128 967,129 185,130 35,131 751,132 103,133 638,134 255,135 785,136 185,137 150,138 260,139 664,140 294,141 863,142 785,143 684,144 395,145 22,146 339,147 667,148 816,149 877,150 65,151 396,152 901,153 847,154 974,155 722,156 315,157 962,158 577,159 938,160 160,161 896,162 548,163 542,164 852,165 34,166 20,167 531,168 404,169 248,170 622,171 126,172 451,173 543,174 814,175 631,176 974,177 423,178 110,179 955,180 554,181 175,182 955,183 577,184 298,185 186,186 894,187 145,188 250,189 659,190 457,191 767,192 25,193 447,194 658,195 957,196 402,197 217,198 557,199 150,200 598,201 636,202 284,203 385,204 414,205 924,206 300,207 214208 ]209 ],210 "output": 16211 },212 {213 "input": [214 [215 411,216 645,217 458,218 749,219 266,220 472,221 819,222 468,223 188,224 631,225 451,226 513,227 368,228 790,229 35,230 677,231 988,232 396,233 770,234 269,235 917,236 46,237 506,238 582,239 682,240 904,241 502,242 182,243 211,244 160,245 218,246 548,247 403,248 18,249 961,250 351251 ],252 [253 668,254 1000,255 676,256 24,257 389,258 903,259 592,260 896,261 30,262 343,263 765,264 537,265 241,266 850,267 579,268 566,269 350,270 757,271 340,272 88,273 814,274 233,275 215,276 371,277 916,278 836,279 245,280 940,281 131,282 936,283 30,284 627,285 113,286 444,287 129,288 111289 ]290 ],291 "output": 7292 },293 {294 "input": [295 [296 478,297 114,298 219,299 666,300 231,301 829,302 926,303 125,304 35,305 578,306 486,307 207,308 647,309 154,310 57,311 717,312 210,313 591,314 347,315 263,316 329,317 622,318 565,319 965,320 732,321 86,322 517,323 972,324 791,325 614,326 488,327 194,328 42,329 395,330 344,331 832,332 192,333 575,334 190,335 675,336 549,337 418,338 426,339 637,340 660,341 337,342 485,343 351,344 629,345 757,346 909,347 963,348 129,349 139,350 708,351 504,352 192,353 129,354 306,355 376,356 640,357 517,358 642,359 598,360 852361 ],362 [363 610,364 739,365 185,366 884,367 715,368 976,369 950,370 64,371 780,372 83,373 179,374 397,375 911,376 683,377 560,378 723,379 946,380 161,381 611,382 524,383 305,384 470,385 70,386 916,387 646,388 577,389 161,390 402,391 491,392 322,393 242,394 466,395 920,396 151,397 342,398 545,399 570,400 685,401 823,402 245,403 152,404 332,405 180,406 806,407 139,408 418,409 206,410 377,411 389,412 256,413 852,414 691,415 225,416 823,417 69,418 873,419 409,420 514,421 307,422 632,423 612,424 502,425 643,426 544,427 934428 ]429 ],430 "output": 9431 },432 {433 "input": [434 [435 855,436 426,437 606,438 929,439 591,440 33,441 138,442 80,443 985,444 56,445 812,446 901,447 795,448 995,449 870,450 983,451 420,452 106,453 222,454 186,455 418,456 32,457 901,458 91,459 429,460 195,461 230,462 875,463 806,464 419,465 54,466 859,467 746,468 681,469 742,470 992,471 515,472 342,473 712,474 222,475 278,476 77,477 558,478 529,479 821,480 176,481 750,482 372,483 635,484 370,485 532,486 237,487 970,488 392,489 629,490 588,491 713,492 851,493 639,494 90,495 665,496 622,497 561,498 93,499 623,500 364,501 36,502 9,503 783,504 607,505 642,506 983,507 347,508 490,509 208,510 546,511 520,512 99,513 465,514 31,515 218,516 431,517 376,518 771,519 530,520 344,521 937,522 565,523 457,524 643,525 471,526 904,527 545,528 213,529 153530 ],531 [532 215,533 175,534 405,535 333,536 903,537 845,538 42,539 873,540 746,541 922,542 572,543 814,544 259,545 309,546 611,547 331,548 767,549 111,550 377,551 736,552 733,553 599,554 29,555 21,556 801,557 461,558 51,559 159,560 445,561 421,562 278,563 593,564 69,565 258,566 60,567 772,568 393,569 73,570 685,571 970,572 890,573 175,574 938,575 220,576 516,577 703,578 891,579 991,580 883,581 166,582 303,583 830,584 291,585 743,586 15,587 837,588 267,589 403,590 563,591 194,592 135,593 469,594 296,595 43,596 59,597 966,598 528,599 135,600 187,601 635,602 376,603 421,604 605,605 929,606 161,607 243,608 212,609 852,610 661,611 92,612 844,613 902,614 28,615 930,616 766,617 352,618 324,619 104,620 403,621 755,622 27,623 299,624 114,625 480,626 958627 ]628 ],629 "output": 22630 },631 {632 "input": [633 [634 287,635 961,636 506,637 125,638 140,639 979,640 604,641 894,642 907,643 555,644 757,645 810,646 385,647 945,648 61,649 154,650 725,651 153,652 921,653 275,654 787,655 36,656 758,657 517,658 147,659 109,660 678,661 401662 ],663 [664 328,665 688,666 564,667 547,668 627,669 951,670 63,671 598,672 455,673 590,674 417,675 577,676 712,677 65,678 449,679 695,680 672,681 943,682 120,683 854,684 911,685 781,686 575,687 189,688 616,689 491,690 76,691 341692 ]693 ],694 "output": 7695 },696 {697 "input": [698 [699 917,700 76,701 164,702 865,703 176,704 616,705 762706 ],707 [708 302,709 83,710 110,711 124,712 484,713 733,714 580715 ]716 ],717 "output": 4718 },719 {720 "input": [721 [722 246,723 601,724 986,725 554,726 800,727 782,728 872,729 94,730 654,731 401,732 714,733 573,734 610,735 60,736 974,737 934,738 32,739 525,740 124,741 447,742 381,743 651,744 860,745 67,746 892,747 123,748 314749 ],750 [751 613,752 866,753 771,754 777,755 788,756 874,757 912,758 89,759 32,760 948,761 61,762 780,763 582,764 765,765 598,766 892,767 661,768 720,769 347,770 64,771 695,772 568,773 606,774 336,775 505,776 277,777 470778 ]779 ],780 "output": 6781 },782 {783 "input": [784 [785 547,786 508,787 659,788 603,789 850,790 549,791 230,792 61,793 310,794 905,795 359,796 247,797 51,798 668,799 348,800 701,801 640,802 810,803 506,804 304,805 564,806 864,807 510,808 118,809 19,810 775,811 203,812 162,813 509,814 197,815 548,816 764,817 646,818 281,819 89,820 562,821 868,822 841,823 988,824 240,825 15,826 641,827 853,828 595,829 355,830 544,831 58,832 34,833 445834 ],835 [836 309,837 734,838 946,839 832,840 469,841 609,842 220,843 296,844 154,845 309,846 106,847 301,848 449,849 187,850 863,851 290,852 845,853 958,854 66,855 214,856 380,857 267,858 714,859 332,860 568,861 349,862 815,863 889,864 755,865 307,866 892,867 390,868 663,869 513,870 453,871 777,872 137,873 697,874 59,875 404,876 708,877 901,878 312,879 301,880 197,881 717,882 793,883 388,884 907885 ]886 ],887 "output": 7888 },889 {890 "input": [891 [892 106,893 115,894 429,895 450,896 299,897 889,898 614,899 520,900 262,901 541,902 297,903 714,904 409,905 718,906 257,907 228,908 188,909 828,910 18,911 496,912 322,913 968,914 45,915 701,916 1,917 140,918 861,919 263,920 651,921 768,922 40,923 362,924 886,925 24,926 95,927 741,928 874,929 846,930 489,931 908,932 234,933 499,934 463,935 986,936 352,937 784,938 274,939 883,940 556,941 151,942 843943 ],944 [945 451,946 316,947 232,948 346,949 359,950 766,951 248,952 973,953 192,954 984,955 294,956 648,957 508,958 680,959 190,960 319,961 239,962 516,963 404,964 2,965 108,966 284,967 130,968 756,969 178,970 398,971 674,972 453,973 999,974 289,975 724,976 208,977 766,978 701,979 722,980 806,981 193,982 127,983 114,984 111,985 541,986 715,987 879,988 942,989 740,990 386,991 742,992 670,993 208,994 571,995 482996 ]997 ],998 "output": 9999 },1000 {1001 "input": [1002 [1003 279,1004 316,1005 333,1006 913,1007 439,1008 315,1009 467,1010 271,1011 619,1012 380,1013 527,1014 735,1015 898,1016 235,1017 850,1018 6671019 ],1020 [1021 215,1022 727,1023 310,1024 334,1025 228,1026 834,1027 670,1028 633,1029 139,1030 745,1031 630,1032 73,1033 197,1034 249,1035 866,1036 8031037 ]1038 ],1039 "output": 51040 }1041 ],1042 "haskell_template": "numOfUnplacedFruits :: [Int] -> [Int] -> Int\nnumOfUnplacedFruits fruits baskets ",1043 "ocaml_template": "let numOfUnplacedFruits (fruits: int list) (baskets: int list) : int = ",1044 "scala_template": "def numOfUnplacedFruits(fruits: List[Int],baskets: List[Int]): Int = { \n \n}",1045 "java_template": "class Solution {\n public int numOfUnplacedFruits(int[] fruits, int[] baskets) {\n \n }\n}",1046 "python_template": "class Solution(object):\n def numOfUnplacedFruits(self, fruits, baskets):\n \"\"\"\n :type fruits: List[int]\n :type baskets: List[int]\n :rtype: int\n \"\"\"\n "1047}