Detail Form
We will send your result on your email id and phone no. please fill detail
Given an array of N positive integers, print k largest elements from the array.
Example 1:
Example 2:
Your Task:
Complete the function kLargest() that takes the array, N and K as input parameters and returns a list of k largest element in descending order.
Expected Time Complexity: O(N log K)
Expected Auxiliary Space: O(K)
Constraints:
1 ≤ N ≤ 104
K ≤ N
1 ≤ array[i] ≤ 105
Given K sorted arrays arranged in the form of a matrix of size K*K. The task is to merge them into one sorted array.
Example 1:
Example 2:
Your Task:
You do not need to read input or print anything. Your task is to complete mergeKArrays() function which takes 2 arguments, an arr[k][k] 2D Matrix containing k sorted arrays and an integer k denoting the number of sorted arrays, as input and returns the merged sorted array ( as a pointer to the merged sorted arrays in cpp, as an ArrayList in java, and list in python)
Expected Time Complexity: O(nk Logk)
Expected Auxiliary Space: O(k)
Constraints:
1 <= K <= 100
Given a N x N matrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the matrix.
Example 1:Example 2:
Expected Time Complexity: O(N*Log(N))
Expected Auxiliary Space: O(N)
Constraints:
1 <= N <= 50
1 <= mat[][] <= 10000
1 <= K <= N*N