leetcode 901 股票价格跨度

简介

简单

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
原文地址:https://www.cnblogs.com/eat-too-much/p/15013200.html