My Blog List

[Leetcode Solution] Merge Two Sorted Lists

Analysis 

  • Use two pointers point to the two input linked list
  • If both pointers are not null, compare the values and link the smaller one at the end of result list
  • If either one is null, link the other to the result list
  • If both are null, stop and return

Note

Code


UPDATED AT LEETCODE 2ND PASS

No comments:

Post a Comment

Enter you comment