Interview
Sliding Window Technique: Maximum Sum Subarray of Size k in O(n)
· Sliding window: max sum subarray of size k | har step pe sirf do kaam
The sliding window technique finds the largest sum of k consecutive numbers without re-adding each window: add the new number, subtract the old one. For [2, 1, 5, 1, 3, 2] with k = 3 the sums are 8, 7, 9, 6, so the max is 9. O(n), not O(n·k).
Interview SheetPractise the patterns behind interview problemsProblems grouped by pattern, each with the idea first and the code in four languages.
![Animated Two Sum walkthrough on the array [3, 8, 4, 6, 1] with target 10: each number asks what it needs, a dictionary stores the numbers already seen, and 6 finds 4, returning indices [2, 3].](https://i.ytimg.com/vi/Fa-tiOP33hY/maxresdefault.jpg)

