Merge two sorted linked lists (Amazon SDE)
Problem - Given two sorted linked lists, merge them so that the resulting linked list is also sorted. Approach - Create a linked list with NULL value, Maintain a head and tail pointer to traverse the linked lists. Choose head of the merged linked list by comparing the first nodes of both the linked lists, the one with lowest value gets inside the merged linked list. Move pointer one step forward and repeat. Code- typedef node * temp ; node * merge_sorted ( temp head1 , temp head2 ) { if ( head1 == NULL ) { return head2 ; } else if ( head2 == NULL ) { return head1 ; } temp mergedhead = NULL ; //merged head if ( head1->data <= head2->data ) { mergedhead = head1 ; head1 =...