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
Boggle Game
BoauthCPP
test
Backtracking_simple
MeanSDVar
3 and 7 in a row
Elevator
runtime template mode processor
memcpy
Bitfield too small to hold all enum values