filmov
tv
Merge Two Sorted Linked Lists | Data Structure & Algorithm | Leet Code

Показать описание
Merge two sorted linked lists and return it as a new linked list
Algorithm :
1- Declare 3 pointers
a- 1st pointer to 1st list's head
b- 2nd pointer to 2nd list's head
c- 3rd pointer to 3rd list's head
2- Compare 1st list data with second list data
3- update list pointer accordingly by moving pointer to next node
4- push data to result list and update list pointer to its next pointer.
Company Tag : Amazon, Microsoft, Snapdeal, Adobe (Courtesy : geekforgeeks)
Algorithm :
1- Declare 3 pointers
a- 1st pointer to 1st list's head
b- 2nd pointer to 2nd list's head
c- 3rd pointer to 3rd list's head
2- Compare 1st list data with second list data
3- update list pointer accordingly by moving pointer to next node
4- push data to result list and update list pointer to its next pointer.
Company Tag : Amazon, Microsoft, Snapdeal, Adobe (Courtesy : geekforgeeks)