#include#include #include using namespace std;//简单的DP算法class Solution {public: int maxProfit(vector &prices) { // Start typing your C/C++ solution below // DO NOT write int main() function int size = prices.size(); if (!size) return 0; vector min(size); min[0] = prices[0]; for (int i = 1; i < size; i++){ min[i] = std::min(min[i-1], prices[i]); } int max = 0; for (int i = 1; i < size; i++){ max = std::max(max, prices[i] - min[i]); } return max; }};int main(){ return 0;}
EOF