Login

All Problems

Problem title

Difficulty

Avg time to solve

Valid Boomerang

Easy

10 mins

Maximum Shares

Easy

30 mins

Homogenous Substrings

Easy

15 mins

Hourglass Pattern

Moderate

--

Score After Flipping Matrix

Moderate

25 mins

Maximum profit

Moderate

40 mins

Ninja and the game

Hard

45 mins

MaxFreq_Element

Moderate

15 mins

Sum of Dependencies in a Graph

Easy

20 mins

Fixed Point

Easy

15 mins

Problem

Submissions

0

Avg. time to solve

30 min

Success Rate

70%

Problem Statement

```
Let,
K = 45
N =3
PRICES = [10, 7, 19]
Answer:- 4
The answer should be 4 because you can purchase 1 stock on day 1,2 stocks on day 2 and 1 stock on day 3. Hence, total amount spent is 10*1 + 7*2 + 19*1 = 43 and number of stocks purchased is 4.
```

```
The first line contains a single integer ‘T’ representing the number of test cases. Then each test case follows.
The first line of each test case contains an integer ‘K’ denoting the initial capital you have.
The second line of each test case contains an integer ‘N’ denoting the number of days for which you know the price for the particular stock.
The third line contains ‘N’ integers of the array ‘PRICES’ denoting the price of the stock on an ith day.
```

```
For each test case, print an integer denoting the maximum amount of stocks you can buy if you act in an optimal manner.
The output of each test case should be printed in a separate line.
```

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

```
1 <= T <= 5
1 <= K <= 10^9
1 <= N <= 10^5
1 <= PRICES[i] <= 10^9
Time Limit = 1 sec
```

```
2
6
3
1 2 3
1
2
3 10
```

```
3
0
```

```
In the first test case, the answer should be 3 because you can buy 1 share on the first day and 2 shares on the second day.
In the second test case, the answer should be 0 because you can’t buy any number of shares on any day.
```

```
1
100
3
7 10 4
```

```
6
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code