Given an array of packages and a window size, return true if any package is a duplicate within the window, otherwise return false.
Explanation: Step-by-step: with input [101, 4, 5, 101, 4, 5], we create a sliding window of size 3. We check if any package is a duplicate within the window. In this case, the package 101 is a duplicate within the window [101, 4, 5]. Therefore, the output is true.
Explanation: Step-by-step: with input [1, 2, 3, 4, 5], we create a sliding window of size 3. We check if any package is a duplicate within the window. In this case, all elements are unique within the window. Therefore, the output is false.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak