|
2 | 2 |
|
3 | 3 | importjava.util.Arrays; |
4 | 4 |
|
5 | | -/** |
6 | | - * 1196. How Many Apples Can You Put into the Basket |
7 | | - * |
8 | | - * You have some apples, where arr[i] is the weight of the i-th apple. You also have a basket that can carry up to 5000 units of weight. |
9 | | - * Return the maximum number of apples you can put in the basket. |
10 | | - * |
11 | | - * Example 1: |
12 | | - * Input: arr = [100,200,150,1000] |
13 | | - * Output: 4 |
14 | | - * Explanation: All 4 apples can be carried by the basket since their sum of weights is 1450. |
15 | | - * |
16 | | - * Example 2: |
17 | | - * Input: arr = [900,950,800,1000,700,800] |
18 | | - * Output: 5 |
19 | | - * Explanation: The sum of weights of the 6 apples exceeds 5000 so we choose any 5 of them. |
20 | | - * |
21 | | - * Constraints: |
22 | | - * 1 <= arr.length <= 10^3 |
23 | | - * 1 <= arr[i] <= 10^3 |
24 | | - * */ |
25 | 5 | publicclass_1196 { |
26 | 6 | publicstaticclassSolution1 { |
27 | 7 | publicintmaxNumberOfApples(int[]arr) { |
|