Add sliding-window module: 12 sliding window and two-pointer interview problems, brute-force cross-checks, dry-run traces, operation counts, pitfalls (11 tests)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6EqSkUWKNBc8i3Q3U
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
Sliding window maximum, k=3, input [1, 3, -1, -3, 5, 3, 6, 7]
|
||||
=============================================================
|
||||
|
||||
right=0 a[right]=1 deque(value@index)=[1@0]
|
||||
right=1 a[right]=3 deque(value@index)=[3@1]
|
||||
right=2 a[right]=-1 deque(value@index)=[3@1, -1@2] -> window max 3
|
||||
right=3 a[right]=-3 deque(value@index)=[3@1, -1@2, -3@3] -> window max 3
|
||||
right=4 a[right]=5 deque(value@index)=[5@4] -> window max 5
|
||||
right=5 a[right]=3 deque(value@index)=[5@4, 3@5] -> window max 5
|
||||
right=6 a[right]=6 deque(value@index)=[6@6] -> window max 6
|
||||
right=7 a[right]=7 deque(value@index)=[7@7] -> window max 7
|
||||
|
||||
answer = [3, 3, 5, 5, 6, 7]
|
||||
Reference in New Issue
Block a user