简介

简单

code
class StockSpanner {
public:
    vector<int> v;
    vector<int> vv;
    StockSpanner() {
        //vector<int> v;
    }
    
    int next(int price) {
        v.push_back(price);
        int cnt = 1;
        for(int i=v.size()-2; i>=0; i-=vv[i]) {
            if(i >=0 && v[i]<=v[v.size() - 1]) {
                cnt+=vv[i];
            }else{
                break;
            }
        }
        vv.push_back(cnt);
        return cnt;
    }
};

Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne