problem
solution
option 1 - reverse Linked Lists
- two pointer to find the middle node
- reverse the second list
- merge two lists
1 | class Solution { |
option 2 - stack
1 | class Solution { |
1 | class Solution { |
analysis
- option 1
- time complexity
O(n)
- space complexity
O(1)
- time complexity
- option 2
- time complexity
O(n)
- space complexity
O(n)
- time complexity