Merge alternate nodes of the two lists
We have already seen the code to merge two sorted linked list, such that the final list is also sorted. The logic and code can be found in this post. In this post, we want to merge the two lists in a way that in the final list, element comes from the two lists alternately […]
Merge two sorted arrays
Given two sorted arrays of size m and n respectively. Also given an empty third array of size (m+n). write code to merge the two arrays and store the result in the third array. INPUT ARRAYS: a = {1, 4, 5, 9} b = {0, 2, 3, 7, 15, 29} OUTPUT: c = {0, 1, […]
Minimum number of platform required for a railway station
Given arrival and departure times of all trains for a particular railway station, write code to find the minimum number of platforms required on that railway station, so that all trains can run according to their schedule.
Merging two Linked List
Given two linked list with Node values sorted in ascending order. Write function that accepts these two linked lists, merge them and return pointer to merged list. In the process Original lists should be deleted (the pointer to head of original lists should be set to NULL)
Find kth element in union of two arrays
Given two sorted arrays of size m and n respectively. Find the kth element in the merged result of A and B. For example, If the inputs (A, B & K ) are as given below Then the merged result of the two arrays will be And the 6th (K’th) element = 8
Merge two arrays into one
There are 2 sorted arrays of size m and m+n respectively. First array (of size m) has m elements and Second array (of size m+n) has only n elements (last m positions are blank). So, the total number of elements in both the arrays is m+n (m in first and n in second). Write code […]