leetcode.nsisong.com

LeetCode playbook

I keep short notes for every problem I solve. Explore the breakdowns, complexity calls, and the exact files that live in this repo.

Latest write-ups

MediumTypeScript
Wiggle Sort II

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

arrayssortinggreedy
MediumPython
Unique Paths II

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

dynamic-programmingmatrix
UnknownC++, Java
Walking Robot Simulation

quick reference for walking robot simulation. more notes soon.

c++java
MediumTypeScript
Largest Plus Sign

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

dynamic-programmingmatrix
UnknownSQL
Movie Rating

quick reference for movie rating. more notes soon.

sql
HardPython
Zuma Game

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

dfsbacktrackingmemoization
UnknownTypeScript
Game Theory

quick reference for game theory. more notes soon.

typescript
HardPHP
Max Points on a Line

find maximum number of points that lie on the same line using slope calculation and hash map.

hash-tablemathgeometry
HardPython
Candy

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

greedyarrays
EasyC
Number of Recent Calls

implement RecentCounter using circular queue to count requests within last 3000ms.

queuedesign
HardPHP
Largest Palindrome Product

find the largest palindrome made from the product of two n-digit numbers using brute force with optimizations.

mathbrute-force
MediumPHP
Maximal Square

find the largest square of 1s in a binary matrix using dynamic programming.

dynamic-programmingmatrix
HardTypeScript
Split Array Largest Sum

find minimum largest sum when splitting array into k subarrays using binary search on answer.

binary-searchgreedyarrays
UnknownScala
Special Array I

quick reference for special array i. more notes soon.

scala
HardTypeScript
LFU Cache

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

designhash-tablelinked-list
HardPython
Word Ladder

find shortest transformation sequence from beginWord to endWord using bfs.

bfsgraphstring
MediumTypeScript
Search a 2D Matrix

binary search on a sorted 2d matrix by treating it as a flattened sorted array.

binary-searchmatrixarrays
HardPython
Palindrome Pairs

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

hash-tablestringtrie
HardPython
Sliding Window Median

find median for each sliding window using sorted list to maintain window in sorted order.

sliding-windowheapsorted-list
UnknownPHP
Addtwonumbers

quick reference for addtwonumbers. more notes soon.

php
HardPHP
Valid Number

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

stringstate-machine
MediumC
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.

matrixarrays
HardTypeScript
Stamping the Grid

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

prefix-summatrixgreedy
HardPHP
Number of Digit One

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

mathdynamic-programming
HardPHP
Strong Password Checker

find minimum steps to make password strong by handling length, character types, and repeating sequences.

greedystring
UnknownC++, Python, TypeScript
0001 Two Sum

quick reference for 0001 two sum. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0007 Reverse Integer

quick reference for 0007 reverse integer. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0009 Palindrome Number

quick reference for 0009 palindrome number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0013 Roman To Integer

quick reference for 0013 roman to integer. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0014 Longest Common Prefix

quick reference for 0014 longest common prefix. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0020 Valid Parentheses

quick reference for 0020 valid parentheses. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0021 Merge Two Sorted Lists

quick reference for 0021 merge two sorted lists. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0027 Remove Element

quick reference for 0027 remove element. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0035 Search Insert Position

quick reference for 0035 search insert position. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0058 Length Of Last Word

quick reference for 0058 length of last word. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0066 Plus One

quick reference for 0066 plus one. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0067 Add Binary

quick reference for 0067 add binary. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0069 Sqrtx

quick reference for 0069 sqrtx. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0070 Climbing Stairs

quick reference for 0070 climbing stairs. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0088 Merge Sorted Array

quick reference for 0088 merge sorted array. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0094 Binary Tree Inorder Traversal

quick reference for 0094 binary tree inorder traversal. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0100 Same Tree

quick reference for 0100 same tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0101 Symmetric Tree

quick reference for 0101 symmetric tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0104 Maximum Depth Of Binary Tree

quick reference for 0104 maximum depth of binary tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0110 Balanced Binary Tree

quick reference for 0110 balanced binary tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0111 Minimum Depth Of Binary Tree

quick reference for 0111 minimum depth of binary tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0112 Path Sum

quick reference for 0112 path sum. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0118 Pascals Triangle

quick reference for 0118 pascals triangle. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0119 Pascals Triangle Ii

quick reference for 0119 pascals triangle ii. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0125 Valid Palindrome

quick reference for 0125 valid palindrome. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0136 Single Number

quick reference for 0136 single number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0141 Linked List Cycle

quick reference for 0141 linked list cycle. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0144 Binary Tree Preorder Traversal

quick reference for 0144 binary tree preorder traversal. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0155 Min Stack

quick reference for 0155 min stack. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0168 Excel Sheet Column Title

quick reference for 0168 excel sheet column title. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0169 Majority Element

quick reference for 0169 majority element. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0171 Excel Sheet Column Number

quick reference for 0171 excel sheet column number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0190 Reverse Bits

quick reference for 0190 reverse bits. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0191 Number Of 1 Bits

quick reference for 0191 number of 1 bits. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0202 Happy Number

quick reference for 0202 happy number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0203 Remove Linked List Elements

quick reference for 0203 remove linked list elements. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0205 Isomorphic Strings

quick reference for 0205 isomorphic strings. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0206 Reverse Linked List

quick reference for 0206 reverse linked list. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0217 Contains Duplicate

quick reference for 0217 contains duplicate. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0219 Contains Duplicate Ii

quick reference for 0219 contains duplicate ii. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0222 Count Complete Tree Nodes

quick reference for 0222 count complete tree nodes. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0225 Implement Stack Using Queues

quick reference for 0225 implement stack using queues. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0226 Invert Binary Tree

quick reference for 0226 invert binary tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0228 Summary Ranges

quick reference for 0228 summary ranges. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0231 Power Of Two

quick reference for 0231 power of two. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0232 Implement Queue Using Stacks

quick reference for 0232 implement queue using stacks. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0234 Palindrome Linked List

quick reference for 0234 palindrome linked list. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0237 Delete Node In A Linked List

quick reference for 0237 delete node in a linked list. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0242 Valid Anagram

quick reference for 0242 valid anagram. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0257 Binary Tree Paths

quick reference for 0257 binary tree paths. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0258 Add Digits

quick reference for 0258 add digits. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0263 Ugly Number

quick reference for 0263 ugly number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0268 Missing Number

quick reference for 0268 missing number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0278 First Bad Version

quick reference for 0278 first bad version. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0283 Move Zeroes

quick reference for 0283 move zeroes. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0290 Word Pattern

quick reference for 0290 word pattern. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0292 Nim Game

quick reference for 0292 nim game. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0303 Range Sum Query Immutable

quick reference for 0303 range sum query immutable. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0326 Power Of Three

quick reference for 0326 power of three. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0338 Counting Bits

quick reference for 0338 counting bits. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0342 Power Of Four

quick reference for 0342 power of four. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0344 Reverse String

quick reference for 0344 reverse string. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0345 Reverse Vowels Of A String

quick reference for 0345 reverse vowels of a string. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0349 Intersection Of Two Arrays

quick reference for 0349 intersection of two arrays. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0350 Intersection Of Two Arrays Ii

quick reference for 0350 intersection of two arrays ii. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0367 Valid Perfect Square

quick reference for 0367 valid perfect square. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0374 Guess Number Higher Or Lower

quick reference for 0374 guess number higher or lower. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0383 Ransom Note

quick reference for 0383 ransom note. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0389 Find The Difference

quick reference for 0389 find the difference. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0392 Is Subsequence

quick reference for 0392 is subsequence. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0401 Binary Watch

quick reference for 0401 binary watch. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0404 Sum Of Left Leaves

quick reference for 0404 sum of left leaves. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0409 Longest Palindrome

quick reference for 0409 longest palindrome. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0412 Fizz Buzz

quick reference for 0412 fizz buzz. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0414 Third Maximum Number

quick reference for 0414 third maximum number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0415 Add Strings

quick reference for 0415 add strings. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0434 Number Of Segments In A String

quick reference for 0434 number of segments in a string. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0441 Arranging Coins

quick reference for 0441 arranging coins. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0455 Assign Cookies

quick reference for 0455 assign cookies. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0459 Repeated Substring Pattern

quick reference for 0459 repeated substring pattern. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0461 Hamming Distance

quick reference for 0461 hamming distance. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0463 Island Perimeter

quick reference for 0463 island perimeter. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0476 Number Complement

quick reference for 0476 number complement. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0482 License Key Formatting

quick reference for 0482 license key formatting. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0485 Max Consecutive Ones

quick reference for 0485 max consecutive ones. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0492 Construct The Rectangle

quick reference for 0492 construct the rectangle. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0495 Teemo Attacking

quick reference for 0495 teemo attacking. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0496 Next Greater Element I

quick reference for 0496 next greater element i. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0500 Keyboard Row

quick reference for 0500 keyboard row. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0504 Base 7

quick reference for 0504 base 7. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0506 Relative Ranks

quick reference for 0506 relative ranks. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0507 Perfect Number

quick reference for 0507 perfect number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0509 Fibonacci Number

quick reference for 0509 fibonacci number. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0520 Detect Capital

quick reference for 0520 detect capital. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0521 Longest Uncommon Subsequence I

quick reference for 0521 longest uncommon subsequence i. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0541 Reverse String Ii

quick reference for 0541 reverse string ii. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0543 Diameter Of Binary Tree

quick reference for 0543 diameter of binary tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0551 Student Attendance Record I

quick reference for 0551 student attendance record i. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0557 Reverse Words In A String Iii

quick reference for 0557 reverse words in a string iii. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0559 Maximum Depth Of N Ary Tree

quick reference for 0559 maximum depth of n ary tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0561 Array Partition

quick reference for 0561 array partition. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0563 Binary Tree Tilt

quick reference for 0563 binary tree tilt. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0566 Reshape The Matrix

quick reference for 0566 reshape the matrix. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0572 Subtree Of Another Tree

quick reference for 0572 subtree of another tree. more notes soon.

c++pythontypescript
UnknownC++, Python, TypeScript
0575 Distribute Candies

quick reference for 0575 distribute candies. more notes soon.

c++pythontypescript
UnknownPython
Candy

quick reference for candy. more notes soon.

python
UnknownErlang, PHP
Contains Duplicate 3

quick reference for contains duplicate 3. more notes soon.

erlangphp
UnknownPHP
Count Of Range Sum

quick reference for count of range sum. more notes soon.

php
UnknownTypeScript
Design Neighbor Sum Service

quick reference for design neighbor sum service. more notes soon.

typescript
UnknownPHP
First Missing Positive

quick reference for first missing positive. more notes soon.

php
UnknownTypeScript
Largest Plus Sign

quick reference for largest plus sign. more notes soon.

typescript
UnknownTypeScript
Magic Squares In Grid

quick reference for magic squares in grid. more notes soon.

typescript
UnknownPHP
Max Points On Line

quick reference for max points on line. more notes soon.

php
UnknownPHP
Maximal Square

quick reference for maximal square. more notes soon.

php
UnknownTypeScript
Maximum Sum Of An Hourglass

quick reference for maximum sum of an hourglass. more notes soon.

typescript
UnknownErlang, PHP
Median Of Two Sorted Arrays

quick reference for median of two sorted arrays. more notes soon.

erlangphp
UnknownPython
Minimum Path Sum

quick reference for minimum path sum. more notes soon.

python
UnknownPHP
Number Of Digit One

quick reference for number of digit one. more notes soon.

php
UnknownPython
Palindrome Pairs

quick reference for palindrome pairs. more notes soon.

python
UnknownPython
Reverse Pairs

quick reference for reverse pairs. more notes soon.

python
UnknownPHP
Russian Doll Envelopes

quick reference for russian doll envelopes. more notes soon.

php
UnknownTypeScript
Search A 2d Matrix

quick reference for search a 2d matrix. more notes soon.

typescript
UnknownC
Set Matrix Zeroes

quick reference for set matrix zeroes. more notes soon.

c
UnknownTypeScript
Simplify Path

quick reference for simplify path. more notes soon.

typescript
UnknownPython
Sliding Window Median

quick reference for sliding window median. more notes soon.

python
UnknownTypeScript
Stamping The Grid

quick reference for stamping the grid. more notes soon.

typescript
UnknownPHP
Strong Password Checker

quick reference for strong password checker. more notes soon.

php
UnknownPython
Two Sum

quick reference for two sum. more notes soon.

python
UnknownPython
Unique Paths Ii

quick reference for unique paths ii. more notes soon.

python
UnknownPHP
Valid Number

quick reference for valid number. more notes soon.

php
UnknownTypeScript
Wiggle Sort Ii

quick reference for wiggle sort ii. more notes soon.

typescript
UnknownErlang, PHP
Wildcard Matching

quick reference for wildcard matching. more notes soon.

erlangphp
UnknownPython
Word Ladder

quick reference for word ladder. more notes soon.

python
UnknownErlang, PHP
Word Ladder 2

quick reference for word ladder 2. more notes soon.

erlangphp
UnknownPython
Zuma Game

quick reference for zuma game. more notes soon.

python
HardPHP
Word Ladder II

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

bfsbacktrackinggraph
UnknownPython
Insertion Sort List

quick reference for insertion sort list. more notes soon.

python
MediumTypeScript
Maximum Sum of an Hourglass

Sliding a fixed hourglass mask through the grid and tracking the best sum with constant-time updates.

arraysprefix-sumgrid
MediumTypeScript
Maximize Area of Square Hole in Grid

Binary search on the side length of the square holes while counting rails removed along each axis.

binary-searchsortinggreedy
MediumTypeScript
String Compression

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

two-pointersstring
UnknownPython
Select Data

quick reference for select data. more notes soon.

python
HardPython
Perfect Rectangle

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

geometryhashing
MediumTypeScript
Magic Squares in Grid

Check every 3×3 window for the 1..9 magic square pattern using center and parity pruning.

gridbrute-forcehashing
UnknownC++
Largest Magic Square

quick reference for largest magic square. more notes soon.

c++
HardTypeScript
Frog Jump

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

dynamic-programmingdfsmemoization
HardPHP
Regular Expression Matching

match string against pattern with . and * using dynamic programming with memoization.

dynamic-programmingstring
HardPHP
Contains Duplicate III

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

sliding-windowbinary-searcharrays
UnknownPython
leetcode intro

overview of my leetcode writeups and plan

math
UnknownPython
basic calculator

basic calculator

stringstackmathrecursion
UnknownPython
skyline problem

skyline problem

treequeuesortingheap
UnknownPython
shortest palindrome

shortest palindrome

arraytwo-pointersstringbacktrackingdesign
MediumPython
3sum

3sum

arraytwo-pointers
MediumPython
combination sum

combination sum

arraybacktracking
MediumPython
permutations

permutations

arraybacktracking
MediumPython
group anagrams

group anagrams

hash-tablestring
MediumPython
maximum subarray

maximum subarray

arraydynamic-programming
UnknownPython
48 my leetcode journey

48 my leetcode journey

arrayhash-tablelinked-listtwo-pointersstring
HardJavaScript
burst balloons

burst balloons

arraystringdynamic-programmingbacktrackinggreedy
HardPython
patching array

patching array

arraybinary-searchdynamic-programmingbacktrackinggreedy
HardPython
Reverse Pairs

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

divide-and-conquermerge-sort
MediumTypeScript
Design Neighbor Sum Service

design a service to compute sums of adjacent and diagonal neighbors using prefix sums and linear search.

designmatrixprefix-sum
HardPHP
Count of Range Sum

count subarrays with sum in range [lower, upper] using prefix sums and merge sort counting.

divide-and-conquerprefix-summerge-sort
HardPHP
Wildcard Matching

match string against pattern with ? and * using dynamic programming.

dynamic-programmingstringgreedy
MediumPython
Minimum Path Sum

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

dynamic-programmingmatrix
UnknownC++
Sort List

quick reference for sort list. more notes soon.

c++
MediumPython
Building H2O

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

concurrencythreading
EasyPython
Two Sum

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

hash-tablearrays
HardPHP
First Missing Positive

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

arrayshashing
HardC
Trapping Rain Water II

calculate trapped rainwater in 2d elevation map using min heap starting from boundary cells.

heapbfsmatrix
UnknownPython
Sort Colors

quick reference for sort colors. more notes soon.

python
UnknownGo
Matrix Block Sum

quick reference for matrix block sum. more notes soon.

go
HardPHP
Russian Doll Envelopes

find maximum number of envelopes that can be nested using longest increasing subsequence on sorted envelopes.

dynamic-programmingbinary-searchsorting
MediumTypeScript
Simplify Path

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

stackstring