Challenge: Merge Two Sorted Lists

Given two sorted lists, merge them into one list which should also be sorted. Implement the solution in Python and see if your code runs successfully.

Problem Statement #

Implement a function that merges two sorted lists of m and n elements respectively, into another sorted list. Name it merge_lists(lst1, lst2).

Input #

Two sorted lists.

Output #

A merged and sorted list consisting of all elements of both input lists.

Sample Input #

list1 = [1,3,4,5]  
list2 = [2,6,7,8]

Sample Output #

arr = [1,2,3,4,5,6,7,8]

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.