100 articles  ·  page 26 of 40

Search a 2D Matrix: Optimal Binary Search, Staircase Elimination & Memory Locality

Algorithmic guide to searching 2D sorted matrices: virtual 1D binary search, top-right staircase elimination, …

LeetCode 543: Diameter of a Binary Tree in C++

Master LeetCode 543 (Diameter of a Binary Tree) in C++: post-order DFS height calculation, eliminating O(N^2) …

401. Binary Watch: Optimal Hamming Weight & Cartesian Search Guide

Master LeetCode 401: Binary Watch in O(1) constant time using hardware popcount, Brian Kernighan bit-clearing,…

Letter Combinations of a Phone Number (LeetCode)

Master LeetCode 17 (Letter Combinations of a Phone Number): combinatorial backtracking DFS, BFS queue generati…

LeetCode 20: Valid Parentheses in TypeScript

Master LeetCode 20 (Valid Parentheses) in TypeScript: LIFO stack mechanics, V8 array internals, early exit bra…

LeetCode 769: Max Chunks To Make Sorted (O(n) Prefix Max)

Solve LeetCode 769 Max Chunks To Make Sorted in O(n) time and O(1) space using the prefix maximum permutation …

1475. Final Prices With a Special Discount in a Shop — Monotonic Stack in C++ & TypeScript

Solve LeetCode 1475 (Final Prices With a Special Discount in a Shop) in O(n) linear time using a monotonic sta…

C++ Solution for Generate Parentheses

Master LeetCode #22 Generate Parentheses in C++20 with backtracking pruning invariants, Catalan numbers combin…

3264. Final Array State After K Multiplication Operations I — Min-Heap in C++ & TypeScript

Solve LeetCode 3264 (Final Array State After K Multiplication Operations I) using a lexicographical min-heap i…

153. Find Minimum in Rotated Sorted Array — O(log n) Binary Search in C++ & TypeScript

Solve LeetCode 153 (Find Minimum in Rotated Sorted Array) in O(log n) time and O(1) space using boundary-conve…

First Non-Repeating Character: O(N) Algorithm Optimization & Stream Processing Guide

A complete technical guide to solving the First Non-Repeating Character problem with O(N) time and O(1) space …

Maximum Difference Between a Pair in a Matrix (2D Suffix DP)

Solve the Maximum Difference Between a Pair in a Matrix problem in O(n^2) time using 2D suffix maximum dynamic…