Efficient Port Traffic Analysis with Sliding Window Technique
Problem Analysis
Given n sequences (n ≤ 1e5) where each contains:
Timestamp t (strict increasing)
Count k (k ≤ 3e5)
k integers
Compute for each sequence x the count of unique integers across all sequences where (tx - t) < 86400 (24 hours in seconds).
Constraints
Partial Score (70pts):
1 ≤ n ≤ 100
Total k ≤ 100
Integer values ≤ 100
Timesta ...
Posted on Wed, 28 Oct 2026 16:48:53 +0000 by andychamberlainuk
Two Pointer and Sliding Window Techniques for Competitive Programming
Two Pointers
Two pointers is a fundamental technique that uses two references to traverse data structures simultaneously. There are two primary variants:
Collision Pointers (Converging Pointers): Both pointers start from opposite ends and move toward each other.
Fast and Slow Pointers: Both pointers move in the same direction but at different s ...
Posted on Mon, 05 Oct 2026 16:20:51 +0000 by maxf
Sliding Window, Spiral Matrix Generation, and Prefix Sum Techniques
LeetCode 209: Minimum Size Subarray Sum
Problem Statement
Given an array of n positive integers and a positive integer target, find the minimum length of a contiguous subaray whose sum is greater than or equal to target. Return 0 if no such subarray exists.
Sliding Window Solution
The sliding window technique provides an elegant O(n) solution. ...
Posted on Sun, 27 Sep 2026 16:36:03 +0000 by ReDucTor
Understanding Monotonic Queues: Efficient Sliding Window Optimization
A monotonic queue is a specialized data structure that maintains elements in either strictly increasing or decreasing order. Unlike standard queues, a monotonic queue allows operations at both the front and rear, functioning as a double-ended queue (deque) where elements are kept in sorted order.
The Core Principle
The fundamental insight behin ...
Posted on Thu, 10 Sep 2026 16:00:59 +0000 by stef686
Sliding Window Technique: Core Patterns and Example Problems
This article provides a concise summary of sliding window templates followed by practical examples. The recommended reading approach: skim the summary first, then study how each template is applied in the examples, and finally revisit the summary to solidify your understanding.
Summary
Problems that are well-suited for the sliding window techni ...
Posted on Sun, 19 Jul 2026 16:06:33 +0000 by wenxi
Efficient Solution for Two-Interval Sum Problem Using Two-Pointer Technique
Problem AnalysisThe problem requires finding, for each position i in an array, the maximum value k such that the sum of elements in the left interval [i, i+k-1] and the sum of elements in the right interval [i+k, i+2*k-1] are both less than or equal to a given value s.Why Binary Search FailsAt first glance, one might consider using binary searc ...
Posted on Thu, 16 Jul 2026 17:10:43 +0000 by flattened
Fixed-Length Sliding Window for String Permutation Problems
Given two strings, we can determine if one contains a permutation of the other using a fixed-length sliding window approach. This technique efficiently checks for character matches by maintaining a window of characters and comparing frequency counts.
Problem 1: Detecting Permutation Substring
For the problem of determining if string s2 contanis ...
Posted on Sun, 14 Jun 2026 17:53:30 +0000 by condoug
Sliding Window and Spiral Matrix Algorithms
Problem Description
Given an array of n positive integers and a positive integer target, find the length of the shortest continuous subarray whose sum is at least target. Return the length of this subarray. If no such subarray exists, return 0.
Example 1:
Input: target = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: The subarray [4,3] has the ...
Posted on Thu, 04 Jun 2026 16:09:14 +0000 by 8mycsh
LeetCode Problem Solutions: Sliding Window and Hash Table Techniques
Trpaping Rain Water Problem
Given an array representing elevation maps, this problem calculates how much water can be trapped between bars after raining.
vector<int> leftMax(n, 0);
vector<int> rightMax(n, 0);
if (n == 0) return 0;
leftMax[0] = height[0];
rightMax[n-1] = height[n-1];
for (int i = 1; i < n; ++i) {
leftMax[i] = ...
Posted on Fri, 15 May 2026 23:00:45 +0000 by jck
Fixed-Size Sliding Window Technique for Identifying String Anagrams
Problem Definition
Given two strings s and p, identify every starting index within s where a substring contains the exact same characters as p with identical frequencies. Character order is irrelevant for matching purposes.
Example: With s = "cbaebabacd" and p = "abc", the qualifying substrings apppear at indices 0 ("cb ...
Posted on Thu, 14 May 2026 07:21:00 +0000 by onyx