Leetcode

Find all my leetcode problem solving notes

I collated all the leetcode problems i solved in here so you can learn from it

23 Oct 2025PythonMedium

Unique Paths II

count paths from top-left to bottom-right with obstacles using dp with space optimization to O(n).

23 Oct 2025TypeScriptMedium

Wiggle Sort II

rearrange array in wiggle pattern (nums[0] < nums[1] > nums[2] < ...) using sorted interleaving.

14 Oct 2025TypeScriptMedium

Largest Plus Sign

find the largest plus sign order by computing longest consecutive 1s in four directions using dp.

03 Sept 2025PythonHard

Zuma Game

find minimum balls needed to clear board using dfs with memoization, trying to form groups of 3+.

26 Aug 2025PythonHard

Candy

distribute candy to children based on ratings using two-pass greedy approach.

24 Apr 2025TypeScriptHard

LFU Cache

implement least frequently used cache with O(1) operations using hash maps and doubly linked lists.

24 Apr 2025PythonHard

Word Ladder

find shortest transformation sequence from beginWord to endWord using bfs.

21 Mar 2025PythonHard

Palindrome Pairs

find all pairs of words that form palindrome when concatenated by checking all prefix/suffix splits.

01 Feb 2025PHPHard

Valid Number

validate if string represents a valid number using state machine or regex.

20 Sept 2024CMedium

Set Matrix Zeroes

set entire row and column to zero when element is zero, using first row and column as markers for O(1) space.

16 Jul 2024TypeScriptHard

Stamping the Grid

check if a grid can be fully covered by stamps using prefix sums and 2d difference array.

30 Jun 2024PHPHard

Number of Digit One

count total number of digit 1 appearing in all numbers from 1 to n using digit dp or mathematical analysis.

06 Jun 2024PHPHard

Word Ladder II

find all shortest transformation sequences from beginWord to endWord using bfs with path tracking.

03 May 2024TypeScriptMedium

String Compression

compress string in-place by replacing consecutive characters with character and count using two pointers.

17 Apr 2024PythonHard

Perfect Rectangle

check if rectangles form exact rectangle without gaps or overlaps using corner counting and area validation.

27 Feb 2024TypeScriptHard

Frog Jump

determine if a frog can cross a river using dfs with memoization, tracking position and last jump distance.

17 Jan 2024PHPHard

Contains Duplicate III

check if there exist two indices with value difference ≤ valueDiff and index difference ≤ indexDiff using sliding window with sorted array.

03 Nov 2023PythonHard

Reverse Pairs

count pairs where nums[i] > 2 * nums[j] and i < j using merge sort with counting during merge phase.

04 Aug 2023PythonMedium

Minimum Path Sum

find minimum sum path from top-left to bottom-right using dynamic programming with space optimization.

27 Jul 2023PythonMedium

Building H2O

coordinate hydrogen and oxygen threads to form water molecules using semaphores and barrier synchronization.

24 Jun 2023PythonEasy

Two Sum

find two indices whose values sum to target using hash map for O(n) lookup.

16 Jun 2023PHPHard

First Missing Positive

find the smallest missing positive integer using array as hash table by placing each number at its correct index.

17 Jan 2023TypeScriptMedium

Simplify Path

normalize unix-style file paths by handling . and .. components using a stack.