Files

26 lines
733 B
Java
Raw Permalink Normal View History

2017-03-10 01:10:37 -06:00
// Author: Rodney Shaghoulian
2018-07-27 16:45:56 -07:00
// Github: github.com/RodneyShag
// HackerRank: hackerrank.com/RodneyShag
2017-03-10 01:10:37 -06:00
import java.util.Scanner;
import java.util.Arrays;
2017-04-05 18:42:35 -05:00
// Time Complexity: O(a + n)
// Space Complexity: O(a)
2017-03-10 01:10:37 -06:00
public class Solution {
private static final int size = 100;
2017-09-11 09:32:17 -07:00
public static void main(String[] args) {
2017-03-10 01:10:37 -06:00
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
2017-04-05 18:42:35 -05:00
int [] counts = new int[size + 1]; // could alternatively use a HashMap
2017-03-10 01:10:37 -06:00
for (int i = 0; i < n; i++) {
counts[scan.nextInt()]++;
}
scan.close();
int maxRepetitions = Arrays.stream(counts).max().getAsInt();
System.out.println(n - maxRepetitions);
}
}