menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Best time ...
source image

Prodevelopertutorial

2w

read

70

img
dot

Best time to buy sell stock

  • To find the best time to buy and sell stocks and maximize profit, we use the concept of minPrice and maxProfit.
  • minPrice represents the minimum price from day 0 to current day, while maxProfit represents the maximum profit from day 0 to current day.
  • Using a loop, we update the minPrice and maxProfit values based on the current day's price.
  • Finally, we return the calculated maxProfit as the result.

Read Full Article

like

4 Likes

For uninterrupted reading, download the app