LeetCode Flashcards
1
Q
p283. Move Zeroes (3)
A
See solution.
2
Q
p344. Reverse String (1)
A
See last solution.
3
Q
p104. Maximum Depth of Binary Tree (1)
A
Solution: DFS
Parameters: n = a tree node.
1. if n is null, return 0.
2. return the 1 + the max of f(n.left) and f(n.right)
4
Q
p237. Delete Node in a Linked List (1)
A
See solution.
5
Q
p136. Single Number (4)
A
See solutions.
6
Q
p206. Reverse Linked List (1)
A
See first solution.
7
Q
p108. Convert Sorted Array to Binary Search Tree (1)
A
Solution: Recursion Parameters: nums = a sorted list of numbers. 1. if nums is empty, return null. 2. m = the middle element of nums. 3. return a new node n a. n.value = m b. n.left = f(nums left of m) c. n.right = f(nums right of m)
8
Q
p169. Majority Element (5)
A
See all solutions except #4.
9
Q
p242. Valid Anagram (2)
A
See solutions.
10
Q
p122. Best Time to Buy and Sell Stock II (1)
A
See solution 3.