class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param weights int整型vector * @return int整型vector */ vector<int> weightGrowth(vector<int>& weights) { // write code here int size = weights.size(); vector<int> res(size, -1); stack<int> stk; stk.push(0); for (int i = 1; i < size; i++) { while (stk.size() && weights[i] > weights[stk.top()]) { res[stk.top()] = i-stk.top(); stk.pop(); } stk.push(i); } return res; } };