*************
C++
topic: 239. 滑动窗口最大值 - 力扣(LeetCode)
*************
Give the topic an inspection.
![]() |
Long time no see. Have too much series too see recently. I have to watch football matches around 苏超. I tryed really hard with no tickets. 大麦倒闭吧, rubbish. And I addicked in <better call saul>, Gus is fucking sexy. He is so professional and relariable. I like him so much and one day, I coubld be him, I could be sherlock, I could be Kumei Ennosuke, and they could be one of me.
|
And the first look I give it a glance, I notice the newest design cocept of Apple Inc.,which is liqued glass. And now I am listening a song called 璀璨冒险人, a good one for my recent days.
![]() |
and back to the topic, I need a variable to store the maximum values and a current maximum to store the maxer on in the array. initialize an empty array and named result.
class Solution {
public:
vector<int> maxSlidingWindow(vector<int>& nums, int k) {
vector<int> result; // 初始化一个空的容器
int n = nums.size(); // 总是要这一步的
for (int i = 0; i <= n - k; i++)
{
int current_max = nums[i]; // 先假设当前值是最大值,方便后续比较,这一步相当于初始化
for (int j = i + 1; j < i + k; j++)
{
current_max = max(current_max, nums[j]); // 这是找出三个钟的最大值
}
result.push_back(current_max); // 之前学的在vector末尾压入
}
return result;
}
};
![]() |
And times out.
Let's try new. Let's very welcome double-ended queue.
I write the above things about two weeks ago. And I am learning PID control recently. Today I have few works to do and the hot days makes me lazy. OK, not the hot days, I am lazy. Even if I am boring and have nothing to do, I donot want to write codes. But just write some code without any emotion. A thought comes to me, which is why I donot understand this when I was young. I was fickal and unpatience.
I donot understand deque. I will back next time.