https://leetcode.com/problems/sliding-window-maximum


Timeout

___


Don't put your energy on useless things.

___


```python
class Solution:
    def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
        #2023/01/11 09:37
        result = []
        for index in range(len(nums)+1-k):
            sliding_window = nums[index: index + k]
            result.append(max(sliding_window))
        return result
        #2023/01/11 09:39
        """
        # wrong version
        my_sliding_list = []
        result = []
        for index in range(len(nums)+1-k):
            if index == 0:
                my_sliding_list = nums[index: index + k].copy()
            else:
                last_element = nums[index-1]
                new_element = nums[index+k-1]
                if (last_element in my_sliding_list) and (nums[index: index + k].count(last_element) == 0):
                    my_sliding_list = [num for num in my_sliding_list if num != last_element]
                if len(my_sliding_list) == 0 or new_element > min(my_sliding_list):
                    my_sliding_list.append(new_element)
                #print(my_sliding_list, nums[index: index + k], last_element, new_element)
            my_sliding_list.sort()
            my_sliding_list = my_sliding_list[-10:]
            result.append(my_sliding_list[-1])
        return result
        """
        #2023/01/11 12:55
```
