top of page
  • Writer's pictureZhiguo Lai

LeetCode 143


The problem can be divided by three steps:

  1. Find the middle elements with two pointers

  2. Reverse the right part by using 3 pointers, we can use the fast pointer before to save more space.

  3. Merge two linked list, check whether the right part have the next node.


The problem can be tackled in these ways

With Time O(n) and Space O(n)

Make a new array and get the elements from the old array

With Time O(n) and Space O (1)

With Time O(nlogn) and Space O (1)

6 views0 comments
bottom of page