Time limit in TestCase 4

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int min = scan.nextInt();
int n = scan.nextInt();
Employee[] arr = new Employee[n];
for(int i=0;i<n;i++){
String name = scan.next();
int salary = scan.nextInt();
arr[i] = new Employee(name,salary);
}
bubbleSort(arr);
display(arr,min);
}
public static void bubbleSort(Employee[] arr){
for(int i =0; i<arr.length-1;i++){
for(int j = 0 ; j< arr.length-1-i;j++){
if(arr[j].salary< arr[j+1].salary){
Employee temp = arr[j];
arr[j] = arr[j+1];
arr[j+1]=temp;

			}else if(arr[j].salary == arr[j+1].salary ){
				if(arr[j].name.compareTo(arr[j+1].name)>0){
					Employee temp = arr[j];
					arr[j]= arr[j+1];
					arr[j+1] = temp;

				}
			}
		}
	}
}
public static void display(Employee[] arr, int min){
	for(Employee val : arr){
		if(val.salary>=min){
			System.out.print(val.name+ " "+ val.salary);
		}
		System.out.println();
	}
}

}
class Employee{
String name;
int salary;
public Employee(String name, int salary){
this.name = name;
this.salary = salary;
}
}

Hi Vaibhav,
Instead of using bubble sort use merge sort or quicksort.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.