4

PROBLEM OF THE DAY : 24/12/2023 | Buy Maximum Stocks if i stocks can be bought o...

 8 months ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-24122023-buy-maximum-stocks-if-i-stocks-can-be-bought-on-i-th-day/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Buy Maximum Stocks if i stocks can be bought on i-th day

December 25, 2023 |90 Views
PROBLEM OF THE DAY : 24/12/2023 | Buy Maximum Stocks if i stocks can be bought on i-th day
Problem of the Day, Array, Data Structures and Algorithms
 Save  Share  1 Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

In this problem, In a stock market, there is a product with its infinite stocks. The stock prices are given for N days, where price[i] denotes the price of the stock on the ith day.
There is a rule that a customer can buy at most i stock on the ith day.
If the customer has an amount of k amount of money initially. The task is to find out the maximum number of stocks a customer can buy.

Example :

Input:
price = [10,7,19]
k = 45
Output: 
4

Explanation: 
A customer purchases 1 stock on day 1, 2 stocks on day 2 and 1 stock on day 3 for 10, 7 * 2 = 14 and 19 respectively. Hence, total amount is 10 + 14 + 19 = 43 and number of stocks purchased is 4.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/buy-maximum-stocks-if-i-stocks-can-be-bought-on-i-th-day/1

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK