https://leetcode.com/problems/merge-two-sorted-lists/submissions/ soultion in both c++ and JavaScript easy question if you know linked list
Merge two linked list solution in c++ -------------------------------------------------------------------------------------------------------------------- c++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) { ListNode *tempNode=new ListNode(); //create a new node ListNode *head=tempNode; //create a new head and assign new node to head while(list1 && list2) //until list1 or list2 not null { ...