Array
LeetCode 118: Pascal's Triangle
·1 min
LeetCode
Easy
Array
Dynamic-Programming
LeetCode 118 note: each row starts and ends with 1, and every inner cell is the sum of the two cells above it
LeetCode 108: Convert Sorted Array to Binary Search Tree
·2 mins
LeetCode
Easy
Array
Divide-and-Conquer
Tree
Binary-Search-Tree
LeetCode 108 note: the middle element becomes the root and each half recurses; the halves differ by at most one, so the tree is balanced
LeetCode 66: Plus One
·2 mins
LeetCode
Easy
Array
Math
LeetCode 66 note: add one from the last digit, turning 9s into 0s while carrying, and prepend 1 when every digit was 9
LeetCode 35: Search Insert Position
·2 mins
LeetCode
Easy
Array
Binary-Search
LeetCode 35 note: find the first position >= target (lower bound); a half-open [l, r) needs r = mid, not r = mid - 1
LeetCode 27: Remove Element
·1 min
LeetCode
Easy
Array
Two-Pointers
LeetCode 27 note: the write pointer copies only values not equal to val, returning how many were written
LeetCode 26: Remove Duplicates from Sorted Array
·2 mins
LeetCode
Easy
Array
Two-Pointers
LeetCode 26 note: overwrite in place with a write pointer for the next slot, writing only values different from the last one written
LeetCode 14: Longest Common Prefix
·2 mins
LeetCode
Easy
Array
String
Trie
LeetCode 14 note: bound by the shortest string and check each position across all strings; the first mismatch gives the answer’s length
LeetCode 1: Two Sum
·2 mins
LeetCode
Easy
Array
Hash-Table
LeetCode 1 note: store seen numbers in a hash map while scanning and look up target - x; checking before storing prevents using one element twice