You are given 2 sorted linked lists with a head pointer. Find a way to merge these 2 lists and return a single sorted list. Try to solve the problem without using any extra space. Example 1:List 1: 1 > 2 > 4List 2: 1 > 3 > 4Output: 1 > 1 > 2 > 3 > 4 > 4 Problem statement To read about Linked Lists, refer to the post “What is a Linked List“? For our current problem statement, we are given two list heads or we refer…
Tag:
Sorting


Question: Given an unsorted array of integers and a number ‘k’. Return the kth largest element in the array.Input: arr = {3,2,1,5,6,4}, k = 2Output: 5 Given an unsorted array of integers, you need to determine the kth largest element. By taking a first glance at the problem we can be sure of one thing. If the array is already sorted in ascending order, we can simply return the element at arr[size – k]. This would give us the kth largest element. This is because the 2nd largest element is…