Hacker News new | ask | show | jobs
by msg 5951 days ago
I give you a file of words, one per line, which may contain duplicates. Output the words in sorted order, removing duplicates, with a count of the number of times it appeared in the original file. Your program should be small and efficient.

So there's file I/O, string matching, string storage, counting probably means a simple data structure, and there's formatted output to print the number of occurrences.

You can also ask deeper questions, such as the big-O of the algorithm/data structure they come up with, and what happens if the file is too large to load in main memory.

Perl programmers (for example) will laugh at this question, but in my experience that puts them ahead of the rest of the interviewing pack.

I ask a similar question in my interviews that has some simple math instead of strings.

I don't demand that my interviewees can remember the name of every library function, but if there's too much handwaving I get suspicious.