LinkedList
key points
dummy node
2 pointers: fast and slow.
while(fast != null && fast.next != null) fast = head, slow = head, fast = fast.next.next, slow = slow.next
, slow stop in the middle or right middle.reverse: track at least 2 points
cycle detection, 2 pointers, Floyd cycle
Reverse
iterative: left + curr + right, 3 points
recursive: return last node
https://leetcode.com/problems/reverse-linked-list/description/ https://leetcode.com/problems/reverse-linked-list-ii/description/ https://leetcode.com/problems/palindrome-linked-list/description/
Cycle
https://leetcode.com/problems/linked-list-cycle/description/ https://leetcode.com/problems/find-the-duplicate-number/description/
Intersection
https://leetcode.com/problems/intersection-of-two-linked-lists/description/
Utilize the next node
https://leetcode.com/problems/copy-list-with-random-pointer/description/
+ - * /
etc operations
+ - * /
etc operationsKey points: carry
curr % 10
curr / 10
Start from right end plus max length max(len1, len2) + 1
, multiply max length len1 + len2
LinkedList
https://leetcode.com/problems/add-two-numbers https://leetcode.com/problems/add-two-numbers-ii/description/ https://leetcode.com/problems/plus-one-linked-list/description/
Array
https://leetcode.com/problems/plus-one/discuss/
String
https://leetcode.com/problems/multiply-strings/description/ https://leetcode.com/problems/add-binary/description/ https://leetcode.com/problems/add-strings/description/
Bit manipulation
https://leetcode.com/problems/sum-of-two-integers/description/
Binary search
https://leetcode.com/problems/sqrtx/description/ https://leetcode.com/problems/powx-n/description/
Linked-List
dummy node
two pointers:
Last updated