Algorithm Problem Solutions: Snowflakes, Sequences, and Graph Theory
Problem 1: Unique Snowflake Collection
Problem Statement: At n different times, snowflakes of various shapes fall (represented by distinct integers). We want to collect snowflakes from time a to time b such that no duplicate shapes are collected, and the total number of snowflakes collected is maximized.
Solution Approach: Two Pointers Techniqu ...
Posted on Thu, 06 Aug 2026 16:35:07 +0000 by mispris006
Detecting Cycles and Removing k-th From End Using Two-Pointer Techniques
Given a singly linked list, determine weather it contains a cycle. Return true if a cycle exists; otherwise, return false. The solution must use O(1) auxiliary space.
This problem is classically solved using Floyd’s Cycle Detection Algorrithm — also known as the "tortoise and hare" approach. Two pointers traverse the list at different ...
Posted on Mon, 20 Jul 2026 16:57:01 +0000 by christian_phpbeginner
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
Removing Elements from Arrays In-Place: LeetCode Problem 27 Analysis
Problem Understanding
The challenge requires removing specific values from an array while meeting these constraints:
Use only O(1) additional space and modify the input array in-place
Element ordering can be changed
Focus only on elements within the new length boundary
The solution will be validated using code similar to:
int result_length = ...
Posted on Tue, 14 Jul 2026 16:26:28 +0000 by draco2317
LeetCode Problem 160: Intersection of Linked Lists
Intersection of Linked Lists
Problem Link
LeetCode 160
Problem Statement
Given the heads of two singly linked lists, headA and headB, return the node at which the two lists intesrect. If there is no intersection, return nullptr.
The linked lists must retain their original structure after the function returns. You are not allowed to modify th ...
Posted on Sun, 05 Jul 2026 16:14:54 +0000 by bobthebullet990
Hash Table Algorithms: Solving Multi-Sum Problems
Hash Table Algorithms: Solving Multi-Sum Problems
4Sum II (LeetCode 454)
Problem Description
Given four integer arrays nums1, nums2, nums3, and nums4, all of length n, return the number of tuples (i, j, k, l) such that:
0 <= i, j, k, l < n
nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0
Example 1:
Input: nums1 = [1,2], nums2 = [-2,-1 ...
Posted on Mon, 22 Jun 2026 16:42:09 +0000 by sanlove
Linked List Operations: Swapping Nodes, Removing Nth Node, Finding Intersections, and Detecting Cycles
Pairwise Node Swapping
To swap adjacent nodes in pairs, we utilize a dummy node to simplify edge cases. The core idea involves manipulating pointers to reverse each pair while maintaining proper linkage with the rest of the list. A cursor pointer tracks the predecessor of each pair being processed.
The termination condition varies based on whet ...
Posted on Sat, 20 Jun 2026 16:35:52 +0000 by matt6805
Mastering Two-Pointer Patterns for Algorithmic Problems
283. Move Zeroes
The objective is to reorganize an array such that all non-zero elements are positioned before any zeros. This operation must be performed in-place without allocating additional space for another array.
Instead of using a secondary buffer, we can utilize a tracking pointer to mark the position where the next non-zero element sho ...
Posted on Thu, 11 Jun 2026 17:56:17 +0000 by coldfused
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
In-Place Removal of Specific Array Values
The objective is to modify an integer array by removing all instances of a specific value directly within the original memory space. The function must return the new length of the array after removal.
Constraints and Mechanics
The solution must adhere to strict space complexity requirements:
O(1) Extra Space: No additional arrays or data struc ...
Posted on Wed, 03 Jun 2026 17:23:48 +0000 by jordy