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
Given an array Arr[] of size N and an integer K, you have to add the first two minimum elements of the array until all the elements are greater than or equal to K and find the number of such operations required.
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Your task is to complete the function minOperations() which takes array of integers arr, n and k as parameters and returns an integer denoting the answer. If it is not possible to make elements greater than or equal to K, return -1.
Expected Time Complexity: O(N*logN)
Expected Auxiliary Space: O(N)
Constraints :
1 ≤ N, K ≤ 105
1 ≤ Arr[i] ≤ 106
You are given an array A of size N. you need to insert the elements of A into a multimap(element as key and index as value) and display the results. Also, you need to erase a given element x from the multimap and print "erased x" if successfully erased, else print "not found".
Input Format:
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains three lines of input. The first line contains N denoting the size of the array A. The second line contains N elements of the array. The third line contains element x that need to be erased from the set.
Output Format:
For each testcase, in a new line, print the required output.
Your Task:
Since this is a function problem, you don't need to take any input. Just complete the provided functions.
Constraints:
1 <= T <= 100
1 <= N <= 1000
1 <= Ai <= 106
Examples: