title: How to get the max number in all sliding windows of an array?
body: <p>Given an array of numbers and a sliding window size, how to get the maximal numbers in all sliding windows?</p>
  
  <p>For example, if the input array is {2, 3, 4, 2, 6, 2, 5, 1} and the size of sliding windows is 3, the output of maximums are {4, 4, 6, 6, 6, 5}. The size of the sliding window is a variable passed to you.</p>
  
  <p>A sliding window is basically a subarray of the original array that starts at a particular index. For instance, at index 0, with size 3, it's the first 3 elements. At index 1, with size 3, it's the 2nd, 3rd and 4th element.</p>
  
  <p>How would you solve this in Java or any other programming language? Or pseudocode, if you so desire.</p>
  
  <p>(Note: This is NOT a homework question, just a question I found on a site that I have my own solution to but want to compare it with others, I'll post my solution below afterwards too)</p>