CodeChef - Turbo Sort
Turbo Sort problem from CodeChef.
Problem
Given the list of numbers, you are to sort them in non-decreasing order.
Input
t
– the number of numbers in the list, then t lines follow [
t
<= 10^6]
.
Each line contains one integer: N
[0 <=
N
<= 10^6]
Output
Output given numbers in non-decreasing order.
Solution in Java:
import java.util.*;
import java.util.Arrays;
class chef{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int[] numbers = new int[T];
int i = 0;
while(T-- > 0){
numbers[i++] = sc.nextInt();
}
Arrays.sort(numbers);
for(int j = 0; j < numbers.length; j++){
System.out.println(numbers[j]);
}
}
}