LeetCode Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

p283. Move Zeroes (3)

A

See solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

p344. Reverse String (1)

A

See last solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

p237. Delete Node in a Linked List (1)

A

See solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

p136. Single Number (4)

A

See solutions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

p206. Reverse Linked List (1)

A

See first solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

p169. Majority Element (5)

A

See all solutions except #4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

p242. Valid Anagram (2)

A

See solutions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

p122. Best Time to Buy and Sell Stock II (1)

A

See solution 3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly