class Solution {
public:
int maxProfit(vector<int> &a) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int minIdx = 0;
int diff = 0;
int res = 0;
for (int i = 1; i < a.size(); ++i)
{
if (a[minIdx] > a[i])
minIdx = i;
if (a[i] - a[minIdx] > res)
{
res = a[i] - a[minIdx];
}
}
return res;
}
};
11-10