Skip to content

Instantly share code, notes, and snippets.

@sangohan
Created June 22, 2011 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sangohan/1039732 to your computer and use it in GitHub Desktop.
Save sangohan/1039732 to your computer and use it in GitHub Desktop.
import it.unimi.dsi.fastutil.objects.*;
public static void main(String[] args) {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
Object2IntMap h = new Object2IntMap();
String l;
int max = 0;
try {
while ((l = stdin.readLine()) != null) {
int x = 1;
if (h.containsKey(l)) {
x = h.getInt(l) + 1;
h.put(l, x);
if (x > max) max = x;
} else h.put(l, 1);
}
} catch (IOException e) {
}
System.out.println(h.size()+"\t"+max);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment