int numTimesAllBlue(vector<int> &light) {
vector<int> v(50010, 0);//初始化灯都没有亮
int ans = 0, temp = 0, cur = 0;
for (auto it:light) {
v[it] = 1;
temp = max(temp, it);
while (v[cur + 1] == 1)
cur++;
if (cur == temp)
ans++;
}
return ans;
}
1375. 灯泡开关 III
最新推荐文章于 2021-11-15 21:21:28 发布