Given an array arr and a number k where k is smaller than size of array, the task is to find the kth smallest element in the given array. It is given that all array elements are distinct.
Answers
Answered by
2
- Let's see another example to get second largest number in java array using collections.
- import java.util.*;
- public class SecondLargestInArrayExample2{
- public static int getSecondLargest(Integer[] a, int total){
- List<Integer> list=Arrays.asList(a);
- Collections.sort(list);
- int element=list.get(total-2);
- return element;
- pls click brainlylist
Similar questions
Math,
6 months ago
Science,
6 months ago
Biology,
6 months ago
India Languages,
11 months ago
Economy,
11 months ago
Computer Science,
1 year ago