Tag: leetcode

Showing 32 posts tagged with "leetcode"

2206. Divide Array Into Equal Pairs

An in-depth algorithmic guide to LeetCode 2206: Divide Array Into Equal Pairs, covering parity invariants, O(N) linear time, and C++ & TypeScript code.

Apple Technical Interview Retrospective: Search a 2D Matrix & Container With Most Water

Retrospective of a 6-round technical interview loop with Apple through Mphasis: Detailed solutions and asymptotic analysis for LeetCode 74 (Search a 2D Matrix) and LeetCode 11 (Container With Most Water).

C++ Solution for LeetCode 2594: Minimum Time to Repair Cars with Binary Search on Answer

Master LeetCode 2594 Minimum Time to Repair Cars in C++20 using binary search on monotonic answers and rank frequency map optimization.

2529. Maximum Count of Positive Integer and Negative Integer

An in-depth algorithmic guide to LeetCode 2529: Maximum Count of Positive Integer and Negative Integer, featuring binary search boundaries and TypeScript code.

Parenthesis Checker: Stack Algorithms, AST Tokenization & Balanced Syntax

Comprehensive guide to the Parenthesis Checker algorithm: LIFO stack mechanics, compiler AST tokenization, edge-case optimization, and TypeScript/C++ code.

LeetCode 2375: Construct Smallest Number From DI String — Monotonic Stack & Two-Pointer Analysis

Algorithmic deep dive on LeetCode 2375 (Construct Smallest Number From DI String): monotonic stack greedy digit reversal, step-by-step trace of IIIDIDDD, and C++20 / TypeScript solutions.

Generating Subsets via Backtracking: LeetCode 1863 XOR Totals & Mathematical O(n) Proof

Algorithmic masterclass on LeetCode 1863 (Sum of All Subset XOR Totals): backtracking state-space trees vs optimal O(n) bitwise OR mathematical proof with C++20, TypeScript, and Python 3 implementations.

Finding the K Largest Elements: Sorting vs. Min-Heap Priority Queues vs. Quickselect

Comprehensive algorithmic guide to finding the K largest elements in an array: full sorting, O(N log K) min-heap priority queue, and O(N) Quickselect.

1079. Letter Tile Possibilities

A comprehensive algorithmic analysis of LeetCode 1079: Letter Tile Possibilities, featuring frequency-map DFS, stack-allocated arrays, and C++ & TypeScript code.

LeetCode 1718: Constructing the Lexicographically Largest Distanced Sequence via Greedy Backtracking

Comprehensive algorithmic guide to LeetCode 1718: greedy backtracking, distanced sequence invariants, early exit optimizations, and C++/TypeScript implementations.

3174. Clear Digits

An in-depth algorithmic guide to LeetCode 3174: Clear Digits, covering LIFO stack mechanics, in-place two-pointer compaction, and C++ & TypeScript code.

In-Order Binary Tree Traversal: Recursive, Iterative Stack & O(1) Space Morris Traversal

Comprehensive algorithmic guide to binary tree in-order traversal: recursive call stack limits, iterative heap stacks, and O(1) space Morris traversal.

LeetCode 3160: Find the Number of Distinct Colors Among the Balls (Dual Hash Map State Machine)

Optimal algorithmic solution for LeetCode 3160: Find the Number of Distinct Colors Among the Balls using a Dual Hash Map State Machine in O(N) time and O(N) space.

LeetCode 1726: Tuple with Same Product — Hash Map Combinatorics & O(n²) Optimization

LeetCode 1726 Tuple with Same Product solution: O(n²) pairwise product hash map, mathematical proof of 8x permutation multiplier, C++20 and TypeScript.

1790. Check if One String Swap Can Make Strings Equal

An in-depth algorithmic guide to LeetCode 1790: Check if One String Swap Can Make Strings Equal, covering mismatch invariants, O(1) space, and C++ & TypeScript code.

Remove Nth Node From End of List: Two-Pointer Fast & Slow Runner Mechanics

Algorithmic guide to removing the Nth node from end of a linked list: single-pass two-pointer runner technique, dummy sentinel nodes, and C++/TypeScript code.

Subarray Sum Equals K: Prefix Sum State Machine, Negative Numbers & Hash Map Frequency Analysis

Complete guide to solving LeetCode 560 Subarray Sum Equals K: Why sliding windows fail on negative numbers, Prefix Sum + Hash Map state machine, C++20 and TypeScript.

1678. Goal Parser Interpretation

A comprehensive guide to LeetCode 1678: Goal Parser Interpretation, covering LL(1) grammars, deterministic single-pass parsing, and V8 string performance.

2559. Count Vowel Strings in Ranges

An in-depth algorithmic guide to LeetCode 2559: Count Vowel Strings in Ranges, covering prefix sum arrays, O(1) range queries, and C++ & TypeScript code.

1030. Matrix Cells in Distance Order

A comprehensive algorithmic guide to LeetCode 1030: Matrix Cells in Distance Order, covering Manhattan distance math, BFS, Bucket Sort, and TypeScript implementations.

LeetCode 1422: Maximum Score After Splitting a String (O(N) Prefix Balance)

Master LeetCode 1422 (Maximum Score After Splitting a String): single-pass O(N) algebraic reduction, prefix balance tracking, and O(1) space proofs.

Why 90% of CS Graduates Struggle with Level-Order Tree Traversal

A deep dive into level-order tree traversal: why candidates struggle, modern C++ std::queue implementations, Boost ptree vs Graph analysis, and TypeScript code.

LeetCode 2466: Count Ways To Build Good Strings — Tabulation DP vs Memoized DFS & Combinatorics

Comprehensive algorithmic guide for LeetCode 2466 (Count Ways To Build Good Strings): tabulation dynamic programming vs memoized DFS, modulo 10^9+7 arithmetic, and C++20 / TypeScript code.

Set Matrix Zeroes: Optimal O(1) Space In-Place Algorithm, Boundary Markers & Cache Locality

Comprehensive guide to solving LeetCode 73 Set Matrix Zeroes in-place with O(1) auxiliary space, resolving (0,0) marker collisions, cache locality, and C++/TypeScript code.

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, cache line locality, and C++/TypeScript code.

LeetCode 543: Diameter of a Binary Tree in C++ & Post-Order DFS

Master LeetCode 543 (Diameter of a Binary Tree) in C++: post-order DFS height calculation, eliminating O(N^2) redundancy, and call stack analysis.

401. Binary Watch

An in-depth algorithmic guide to LeetCode 401: Binary Watch, featuring Cartesian search, bit manipulation, and C++ & TypeScript code.

Letter Combinations of a Phone Number: Combinatorial Backtracking & T9 Algorithms

Master LeetCode 17 (Letter Combinations of a Phone Number): combinatorial backtracking DFS, BFS queue generation, O(3^N * 4^M) complexity, and T9 systems.

LeetCode 20: Valid Parentheses in TypeScript & V8 Stack Mechanics

Master LeetCode 20 (Valid Parentheses) in TypeScript: LIFO stack mechanics, V8 array internals, early exit branch pruning, and O(N) complexity proofs.

C++ Solution for Generate Parentheses (LeetCode #22): Backtracking & Catalan Numbers

Master LeetCode #22 Generate Parentheses in C++20 with backtracking pruning invariants, Catalan numbers combinatorics, and memory buffer optimization.

Minimum Characters to Add for Palindrome: Algorithms & Solutions

A complete algorithmic guide to solving the Minimum Characters to Add for Palindrome problem in O(N) linear time using KMP LPS preprocessing.

Find Peak Element: Logarithmic Binary Search Algorithm, Proof & Multi-Language Guide

Master the Find Peak Element algorithm (LeetCode 162) in O(log n) logarithmic time. Mathematical convergence proof on unsorted arrays with C++20, TypeScript, and Python 3 implementations.