For each item in the inputlist we run a nested while loop below
while ((!window.isEmpty()) && nums.get(i) >= nums.get(window.peekLast()))
which can iterate the size of window in worse case scenario for each item in the inputarray.
why then the complexity is stated as O(n)? is’nt it O(wn)? where w is the window size and n is the nums.size();
Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Find Maximum in Sliding Window - Grokking Coding Interview Patterns in Java
Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Find Maximum in Sliding Window - Grokking Coding Interview Patterns in Java
Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Find Maximum in Sliding Window - Grokking Coding Interview Patterns in Java
Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Find Maximum in Sliding Window - Grokking Coding Interview Patterns in Java