Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added buy and sell stocks code in cpp #4748

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DhruvTotala
Copy link

What type of PR is this? (check all applicable)

  • [X ] πŸš€ Added Name
  • [ X] ✨ Feature
  • [ X] 🌟 stared the repo
  • [X ] πŸ› Grammatical Error
  • [X ] πŸ“ Documentation Update
  • [ X] 🚩 Other

Description

nput:

We first ask the user to input the number of days n.
Then, the user provides the stock prices for each day as input.
Logic:

The function maxProfit calculates the maximum profit by iterating through the stock prices.
min_price keeps track of the lowest price seen so far.
max_profit is updated if the difference between the current price and the min_price gives a higher profit.
Output:

The program outputs the maximum possible profit.

Add Link of GitHub Profile

https://github.com/DhruvTotala

@DhruvTotala
Copy link
Author

@keshavsingh4522 please review my code and suggest necessary changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant