The goal of the problem is to find the maximum value in every contiguous subarray (or “window”) of size k within the input array nums.
This brute force algorithm iterates through all possible starting indices of the sliding window and calculates the maximum value for each window.
An efficient solution using a deque (double-ended queue) is provided to improve the time complexity to O(n) by avoiding redundant comparisons.
By leveraging the deque, the algorithm ensures that the maximum value for each window is computed in constant time, making it well-suited for large input arrays.