New update is available. Click here to update.

Last Updated: 21 Jul, 2020

Difficulty: Moderate

```
Array index 'i' denotes the cost of (i+1)kg packet.
Example: cost[0] is the cost of a 1kg packet of oranges.
```

```
The first line of each test case contains two single space-separated integers 'N' and 'W' where 'N' denotes the size of the array/list(cost), and 'W' is the bag's size.
The second line of each test case contains 'N' single space-separated integers denoting the values of the cost.
```

```
Print the minimum cost to buy exactly W kg oranges. If it's impossible, print "-1".
```

```
You are not required to print anything, it has already been taken care of. Just implement the function.
```

```
1 <= N <= 1000
1 <= W <= 1000
-1 <= cost[i] <= 1000000
Time Limit: 1sec
```

Popular Interview Problems: