Counting Sort 3

  • + 0 comments
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int[] arr = new int[100];
    
            for (int i = 0; i < n; i++) {
                int val = scanner.nextInt();
                String s = scanner.next();
                arr[val]++;
            }
    
            int sum = 0;
            for (int i = 0; i < 100; i++) {
                sum += arr[i];
                System.out.print(sum + " ");
            }
    
            scanner.close();
        }
    }