Binary Search Patterns: Solving Common LeetCode Array Problems
Binary search is a fundamental algorithm that efficiently locates target values in sorted arrays. This article explores several classic LeetCode problems that leverage binary search, along with related array manipulation techniques.
Problem 704: Binary Search
When performing binary search on a sorted array, the choice of boundary conditions sig ...
Posted on Wed, 24 Jun 2026 16:35:07 +0000 by Lefu
Fundamentals of Sorting Algorithms and Complexity Analysis in C
Algorithmic Complexity Fundamentals
Algorithm performance is measured by execution duration and memory consumption. Time complexity quantifies the growth rate of operations relative to input size, while space complexity tracks auxiliary storage requirements. Engineers frequently accept higher memory usage to achieve faster runtimes. As input si ...
Posted on Tue, 23 Jun 2026 17:01:09 +0000 by snowplank
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
Merge Sort Implementation for Singly Linked Lists
Algorithm Overview
Split: Use slow-fast pointer technique to locate the midpoint and partition the list into two halves.
Recurse: Apply the same sorting procedure recursively on both halves.
Merge: Combine the two sorted sublists into a single sorted list using a linear-time merge step.
Implementation
class ListNode {
int value;
ListN ...
Posted on Fri, 19 Jun 2026 17:24:15 +0000 by brainstem
Understanding the FIFO Queue Data Structure
Definition and Core Principles
A Queue is a fundamental linear data structure that operates on the First-In-First-Out (FIFO) principle. Conceptually, it functions similarly to a real-world waiting line: entities enter from one end, known as the rear, and exit from the opposite end, known as the front. This strict ordering ensures that the eleme ...
Posted on Fri, 19 Jun 2026 16:41:24 +0000 by disconne
Efficient Sorting and Merging with Heap Data Structures
Heap Data Structure Implementation
Heaps are specialized tree-based data structures that satisfy the heap property. They are commonly used to implement priority queues and for efficient sorting algorithms. This article explores two practical applications of heaps: heap sort and sequence merging.
Heap Sort Implemantation
Heap sort is an efficien ...
Posted on Thu, 18 Jun 2026 16:37:37 +0000 by Eddie Fisher
FHQ Treap: A Non-Rotating Balanced Binary Tree Implementation
Data Structure DefinitionThe FHQ Treap (Fredman, Hendler, and Zhou Treap) relies on a randomized heap priority to maintain balance without requiring complex tree rotations. Each node in the structure maintains essential metadata: pointers to left and right children, the node's value, a random priority weight, and the size of the subtree rooted ...
Posted on Wed, 17 Jun 2026 17:45:38 +0000 by Backara_Drift
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
Solving the Two Sum Problem with Python
The objective is to identify two numbers within an integer array that sum up to a specific target value and return their indices. It is assumed that there is exactly one valid solution per input and that an element cannot be used twice.
For example, given the array nums = [2, 7, 11, 15] and target = 9, the function should return [0, 1] becuase ...
Posted on Tue, 16 Jun 2026 17:01:38 +0000 by ciaranmg
Algorithmic Review and Competition Strategies for NOIP
Contest preparation requires a structured approach to covering fundamental algorithms and optimizing problem-solving strategies. The following outlines core technical topics and execution practices essential for competitive programming.
Core Algorithms and Data Structures
Simulation and Mathematics
High-precision arithmetic is critical for p ...
Posted on Mon, 15 Jun 2026 17:54:23 +0000 by press711