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
Tree Visibility Problem: Maximum Trees Visible Through a Telescope Window
Problem Description
Consider a road that is 20 meters long with tree pits located every 1 meter. The tree pits are numbered from left to right as 0, 1, 2, ..., 20. Some of these pits contain trees, with each pit holding at most one tree.
A person is standing at a window with a telsecope and can observe exactly 4 consecutive tree pits at a time ...
Posted on Mon, 11 May 2026 09:41:26 +0000 by fasmy98
Java Algorithm Patterns: Hash Maps to Array Manipulation
Hash Map Techniques
LeetCode 1: Two Sum
Utilize a hash map to store elements not yet encountered, while searching for the complement target - nums[i].
public int[] twoSum(int[] nums, int target) {
int[] result = new int[2];
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
in ...
Posted on Fri, 08 May 2026 12:03:41 +0000 by SyWill
Codeforces Round #575 Div 3 Algorithmic Solutions and Analysis
Problem A: Equilibrium Distribution
The objective requires calculating the maximum uniform amount two participants can receive by redistributing three initial piles. The mathematical foundation relies on summing all available items across the piles and performing integer division by two. Since any remainder must remain undistributed to satisfy ...
Posted on Thu, 07 May 2026 07:24:23 +0000 by jorley