Files
HackerRank-Solutions/Algorithms/Sorting/Counting Sort 2/Solution.java
T

29 lines
761 B
Java
Raw Normal View History

2017-03-24 00:02:30 -05:00
// Author: Rodney Shaghoulian
2018-07-27 16:45:56 -07:00
// Github: github.com/RodneyShag
// HackerRank: hackerrank.com/RodneyShag
2017-03-24 00:02:30 -05:00
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
final int maxValue = 100;
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] array = new int[maxValue];
/* Save into buckets */
for (int i = 0; i < n; i++) {
int num = scan.nextInt();
array[num]++;
}
scan.close();
/* Print all elements, sorted */
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i]; j++) {
System.out.print(i + " ");
}
}
}
}