Sliding Window Technique and Spiral Matrix Generation
Minimum Size Subarray Sum
Given an array of positive integers nums and a positive integer target, find the minimal length of a contiguous subarray whose sum is greater than or equal to target. If no such subarray exists, return 0.
Examples:
Input: target = 7, nums = [2,3,1,2,4,3]Output: 2Explanation: The subarray [4,3] has the minimal lengt ...
Posted on Tue, 16 Jun 2026 17:11:50 +0000 by kusarigama
Efficient Array Algorithms: Two Pointers, Sliding Windows, and Matrix Simulation
Squares of a Sorted Array (LeetCode 977)
The challenge in squaring a sorted array that contaisn negative numbers is that the largest squares can appear at both ends of the array. While a naive solution involves squaring every element and then sorting the array in $O(n \log n)$ time, a more efficient $O(n)$ approach utilizes the two-pointer tech ...
Posted on Wed, 20 May 2026 06:33:31 +0000 by jskywalker
Java Algorithm Practice: Squares of Sorted Arrays, Minimum Size Subarray Sum, and Spiral Matrix II
977. Squares of a Sorted Array
Problem Link on LeetCode
Approach: Two Pointers Technique Since the array may contain negative numbers, we use two pointers to compare the squares of the elements from both ends. The left pointer starts at the beginning of the array, and the right pointer starts at the end. The larger square is placed at the curre ...
Posted on Thu, 14 May 2026 22:08:44 +0000 by cmanhatton
Sliding Window Maximum and Minimum
Given an aray of size n ≤ 10^6, determine the maximum and minimum values in each sliding window of size k.
Input:
Two integers n and k representing the array length and window size.
A line containing n integers representing the array elements.
Output:
Two lines containing the minimum and maximum values for each sliding window positino.
Exam ...
Posted on Thu, 14 May 2026 03:02:25 +0000 by Hatch
Finding the Maximum Number of Vowels in a Fixed-Length Substring
Given a string s and an integer k, the objective is to determine the highest possible count of vowel letters within any contiguous substring of length k. Vowel letters are defined as 'a', 'e', 'i', 'o', 'u'.
A sliding window approach provides an efficient solution. The algorithm first calculates the vowel count in the initial window of size k. ...
Posted on Wed, 13 May 2026 10:20:16 +0000 by invictive
Calculating the Length of the Longest Substring Without Repeating Characters
Given a string, identify the length of its longest contiguous substring containing no duplicate cahracters.
Example 1:
Input: "abcabcbb"
Output: 3
Explanation: The longest substring without repeating characters is "abc", which has a length of 3.
Example 2:
Input: "bbbbb"
Output: 1
Explanation: The longest substrin ...
Posted on Thu, 07 May 2026 14:57:56 +0000 by rmbarnes82