Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Best Time to Buy and Sell Stock
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given an array of stock prices, find the maximum profit you can achieve.
Sample Input:
[7,1,5,3,6,4]
Sample Output:
5
Hints
Hint 1
Track the minimum price seen so far
Hint 2
Calculate profit at each day as current price - min price
Hint 3
Update maximum profit accordingly
Code Editor
Reset
Run
Save
Loading...