Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Best time to buy and sell stocks
class Solution { public: int maxProfit(vector<int>& v) { int mi=1e9; int n=v.size(); int profit=0; for(int i=0;i<n;i++) { mi=min(mi,v[i]); if(v[i]>mi) { profit=max(profit,(v[i]-mi)); } } return profit; } };
run
|
edit
|
history
|
help
0
inorder traversal
Find the max and min number in array
sd5
Bucket Graph Creation
graph representation Adjacency List
xyp
Breakfast Function
grid
Web Browser History - DLL
cppPyClass