Problem Statement |
| John and Brus have their own airplane. They are going to take several consecutive flights.
The i-th element of flights is the number of liters of fuel needed for the i-th flight.
The flights can be performed only in the same order as they are described in flights.
Initially there are fuel liters of fuel in the airplane. In order to perform a flight, the amount of fuel in the airplane must be at least as much as the amount of fuel needed for this flight. Return the maximum number of flights they will be able to make without a refuel.
|
|
Definition |
| Class: | TheAirTripDivTwo | Method: | find | Parameters: | int[], int | Returns: | int | Method signature: | int find(int[] flights, int fuel) | (be sure your method is public) |
|
|
|
|
Constraints |
- | flights will contain between 1 and 47 elements, inclusive. |
- | Each element of flights will be between 1 and 1000, inclusive. |
- | fuel will be between 1 and 1000, inclusive. |
|
Examples |
0) | |
| | Returns: 4 | Exactly 10 liters of fuel are required to perform the first four flights. |
|
|
1) | |
| | Returns: 1 | These are the same flights as in the previous example, but in different order. |
|
|
2) | |
| |
3) | |
| |