LinkedList Merge
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
Definition of a single linked list:
// Java class ListNode { int val; ListNode next; ListNode(int x) { val = x; next = null; } }
// C++ class ListNode { public: int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };
Implement function merge that merges two linked lists.
// Java ListNode merge(ListNode l1, ListNode l2)
// C++ ListNode* merge(ListNode *l1, ListNode *l2)
Example
Submissions 3K
Acceptance rate 37%