Steps:
1. Iterate through the array nums from index 0 to len(nums) – k.
2. For each window of size k, find the maximum element.
3. Store the maximum value for each window in the result list.
4. Return the result list.
class Solution:
def maxSlidingWindow(self, nums, k):
result = []
for i in range(len(nums) - k + 1): # Loop through all windows
max_value = max(nums[i:i + k]) # Get max in current window
result.append(max_value)
return result
# Example usage
solution = Solution()
print(solution.maxSlidingWindow([1,3,-1,-3,5,3,6,7], 3)) # Output: [3,3,5,5,6,7]