1 | function insert(A: number[][], T: number[]): number[][] { |
80. Remove Duplicates from Sorted Array II
1 | var removeDuplicates = function(nums) { |
97. Interleaving String
https://leetcode.com/problems/interleaving-string/?envType=study-plan-v2&envId=top-interview-150
Solution1:
1 | class Solution: |
Solution2:
1 | class Solution: |
64. Minimum Path Sum
https://leetcode.com/problems/minimum-path-sum/description/
1 | class Solution: |
62. Unique Paths
https://leetcode.com/problems/unique-paths/description/
Solution1: top down dp
1 | class Solution: |
Solution2: bottom up dp
1 | class Solution: |
45. Jump Game II
https://leetcode.com/problems/jump-game-ii/
We always make our furthest step and when i is bigger than far
, we need to make one more step.
1 | class Solution: |
131. Palindrome Partitioning
https://leetcode.com/problems/palindrome-partitioning/
1 | class Solution: |
79. Word Search
https://leetcode.com/problems/word-search/
1 | class Solution: |
We can set A[x][y]
as # to mark it as visited to prevent the same cell from being visited more than one time.
1 | class Solution: |
148. Sort List
https://leetcode.com/problems/sort-list/
Solution1: hash table
1 | class Solution: |
1 | var sortList = function(head) { |
TopDown merge sort
Divide:
The original list is divided into two halves. And we repeat the process until the base case is reached, which is a sublist of 0 or 1 element.
Conquer:
The list that has 0 or 1 element is originally sorted.
Combine:
We merge two sorted sublist into a single sorted list.
1 | var sortList = function(head) { |
138. Copy List with Random Pointer
Solution1: hash table
1 | class Solution: |