Amazon Interview Question
Software Engineer / DevelopersOne other way would be to use a string hashing algorithm on the lines of the files and then keeping the resulting hash values inside a map (or dictionary) to their line numbers. Whenever we encounter one of the hashes we stored in map before, we can get the associated line number and return it along with the current line number.
Put each line to a list and use sort() and unique()
- FooBar May 23, 2008