LeetCode
LeetCode 43: Multiply Strings
·2 mins
LeetCode
Medium
Math
String
Simulation
LeetCode 43 note: num1[i] × num2[j] lands at position i + j + 1; accumulate into an array of length n + m and carry at the end
LeetCode 40: Combination Sum II
·2 mins
LeetCode
Medium
Array
Backtracking
LeetCode 40 note: each number is used once and duplicates exist, so sort, start the next level at i + 1, and skip equal values within a level
LeetCode 39: Combination Sum
·2 mins
LeetCode
Medium
Array
Backtracking
LeetCode 39 note: numbers may be reused, so the next level starts at i (not i + 1), which also avoids duplicates differing only in order
LeetCode 36: Valid Sudoku
·2 mins
LeetCode
Medium
Array
Hash-Table
Matrix
LeetCode 36 note: each digit may appear once per row, column and 3 × 3 box; put (digit, row), (digit, column) and (digit, box) keys into one set
LeetCode 34: Find First and Last Position of Element in Sorted Array
·3 mins
LeetCode
Medium
Array
Binary-Search
LeetCode 34 note: two lower bounds: the first position >= target, and the first position >= target + 1 minus one
LeetCode 33: Search in Rotated Sorted Array
·3 mins
LeetCode
Medium
Array
Binary-Search
LeetCode 33 note: after rotation one side of mid is always sorted; check whether the target lies in it and search there, otherwise search the other side
LeetCode 31: Next Permutation
·3 mins
LeetCode
Medium
Array
Two-Pointers
LeetCode 31 note: from the right find the first dip i, swap it with the smallest larger value to its right, then reverse everything after i, with comparisons that include equality
LeetCode 24: Swap Nodes in Pairs
·2 mins
LeetCode
Medium
Linked-List
Recursion
LeetCode 24 note: a dummy plus pairs, rewiring prev.next, a.next and b.next together; swap nodes, not values
LeetCode 5: Longest Palindromic Substring
·2 mins
LeetCode
Medium
Two-Pointers
String
Dynamic-Programming
Manacher
LeetCode 5 note: expand around centers, using each position as an odd and an even center; with interval DP, iterate i from large to small
LeetCode 19: Remove Nth Node From End of List
·2 mins
LeetCode
Medium
Linked-List
Two-Pointers
LeetCode 19 note: from a dummy, move fast n + 1 steps ahead, then move both to the end; slow stops before the node to delete
LeetCode 18: 4Sum
·2 mins
LeetCode
Medium
Array
Two-Pointers
Sorting
LeetCode 18 note: sort, fix the first two numbers with two loops, and converge pointers for the rest, skipping equal values at all four positions
LeetCode 17: Letter Combinations of a Phone Number
·2 mins
LeetCode
Medium
Hash-Table
String
Backtracking
LeetCode 17 note: each level handles one digit and tries its letters; an empty input returns an empty list