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

Day 193 #399

Closed
vaskoz opened this issue Mar 4, 2019 · 0 comments
Closed

Day 193 #399

vaskoz opened this issue Mar 4, 2019 · 0 comments
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Mar 4, 2019

Good morning! Here's your coding interview problem for today.

This problem was asked by Affirm.

Given a array of numbers representing the stock prices of a company in chronological order, write a function that calculates the maximum profit you could have made from buying and selling that stock. You're also given a number fee that represents a transaction fee for each buy and sell transaction.

You must buy before you can sell the stock, but you can make as many transactions as you like.

For example, given [1, 3, 2, 8, 4, 10] and fee = 2, you should return 9, since you could buy the stock at 1 dollar, and sell at 8 dollars, and then buy it at 4 dollars and sell it at 10 dollars. Since we did two transactions, there is a 4 dollar fee, so we have 7 + 6 = 13 profit minus 4 dollars of fees.

@vaskoz vaskoz self-assigned this Mar 4, 2019
@vaskoz vaskoz mentioned this issue Mar 10, 2019
@vaskoz vaskoz mentioned this issue Jan 8, 2020
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

No branches or pull requests

1 participant