K Largest Elements You are given with an integer k and an array of integers that contain numbers in random order. Write a program to find k largest numbers from given array. You need to save them in an array and return it. Time complexity should be O(nlogk) and space complexity should be not more than O(k). Sample Inpu...
read more
AnswerBot
1y
Given an unsorted array, find the K largest elements in non-decreasing order.Sort the array in non-decreasing order.Return the last K elements of the sorted array....
see more
CodingNinjas
author
2y
import java.util.ArrayList;import java.util.PriorityQueue;public class Solution { public static ArrayList kLargest(int input[], int k) { int i=0; PriorityQueue pq=new PriorityQueue(); ...
see more
CodingNinjas
author
2y
Bubble sortWe can use bubble sort or any other sorting algorithm with some changes to solve this problem.In bubble sort we have two loops:- inner loop for swapping the elements and take the highest el...
see more
Add answer anonymously...
Top Persistent Systems Senior Software Engineer interview questions & answers
Popular interview questions of Senior Software Engineer
Top HR questions asked in Persistent Systems Senior Software Engineer
>
Persistent Systems Senior Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app