Intend to solve problems in Python3 or C.
C
:
- Swap Nodes in Pairs
- (important) O(n) solution is subtle. Remember it.
Python
:
- Merge k Sorted Lists
- Swap Nodes in Pairs
- Reverse Nodes in k-Group
- Remove Duplicates from Sorted Array
- Remove Element
- Implement strStr()
- Divide Two Integers
- Substring with Concatenation of All Words
- (*a)Next Permutation
- Substring with Concatenation of All Words
- Search in Rotated Sorted Array
- Find First and Last Position of Element in Sorted Array
- Search Insert Position
- Valid Sudoku
- Sudoku Solver
- Count and Say
- Combination Sum
- Combination Sum II
- First Missing Positive
- Trapping Rain Water
- Multiply Strings
- Wildcard Matching
- Jump Game II
- Permutations
- Permutations II
- Rotate Image
- Group Anagrams
- Pow(x, n)
- N-Queens
- N-Queens II
- Maximum Subarray
- Spiral Matrix
- Jump Game
- Merge Intervals
- Insert Interval
- Length of Last Word
- Spiral Matrix II
- Permutation Sequence
- Rotate List
- Unique Paths
- Unique Paths II
- Minimum Path Sum
a. The difference between listA.reverse() and listA[::-1]
from 2019/10/18
- iterate from the very last, find the second-minima
- (difficult)DP
- Two Binary Search(one for seeking pivot point)
- Binary Search
- Binary Search, or iterate from the beginning
- Check Row, Column, Block (Three loops)
- Recursive
- Recursive
- Recursive, determine the same set?
- Recursive, how to prevent repeated answer
- (difficult) Time Complexity O(n), Space Complexity O(1), use the origin matrix as an index array
- DP, Time Complexity O(n) ~= 3n
- Use array representation to do multiplication
- (difficult)DP,
- Greedy!
- Recursive
- for duplicate input, sort and targeting each unique number only once
^
[1,1,1,1,1,3,4]
^
[1,1,1,1,1,3,4]
^
[1,1,1,1,1,3,4]
- transpose and reverse
- sorted string, O = nmlogm, n=len(strs), m=len(str)
- (Not recommended) recursive
- 8 queens, recursive
- == 51
# How to allocate a 2D array in python
# The following example gives you a 3*3 array
n = 3
arr = [[0 for i in range(n)] for j in range(n)]
# How to copy a 2D array in python
cp_arr = [row[:] for row in arr]
# ps. how to copy a 1D array in python
arr = [0] * n
cp_arr = arr[:]
-
(interesting)
- transpose, divide and conquer, resursive
- directly spiral iteration
-
.= 45
-
merge, extend the upper bound
-
insert and merge(56.)
-
Trival
-
Trival
-
Calculate fatorial
-
Linked List
-
Trival
-
dp?
-
dp?
-
Trival
-
Binary addition
-
Trival but a lot of traps
-
Binary Search
-
Don't use recursive, try combination
=== From now on, only focus on problems whose likes more than dislikes ===
-
Try to use less space: Optimal O(1), but mine is O(m+n)
-
Binary Search in two dimension
-
Trival
-
(not-complete)
-
Recursive, (Is there a better solution?)
-
Recursive (faster than 71.13%)
-
Recursive (faster than 96.68%)
-
Trival
-
(compare to 33) (faster than 33.34%, O(n)) Is there a O(log(n)) solution?
-
Linked List
-
Linked List
-
(difficult)(Need to be recoded!) Not A very elegant solution
-
(difficult)
-
(Again)Partition, (using an buffer to store require space O(n), try not to use?)
-
Replace in place. (faster than 63.xx%)
-
Recursive
-
pick, reverse, and concatenate
-
Calculate all combination First
-
(Trival) What is inorder(LVR) / postorder(LRV) / preorder(VLR)
-
(faster than 94.83%) Similar to 96. Recursive
-
(Trival) Divide and Conquer
-
(difficult, important) dp, manage 2D array
-
(important) Validate BST
-
(slow) simply recursively compare
-
(faster than 8.18%) simple recursion (faster than 81.35%) loop solution
-
(faster than 97.37%) similar to 102.
-
(faster than 93.69%) simple recursion
-
(faster than 9.18%) divide and conquer, recursion (Find root node)
-
(faster than 8.03%) similar to 105.
-
(faster than 6.35%) divide and conquer
Updated on 2019/12/1