Then there was software development problem, to write down Java application, 1 file, not more than 50 lines of code, which read given file (63kb) of text, find all words there and print list of words with number of their occurences. This programm should work less than 100ms.
Sigiloso
package Main; import java.io.*; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; public class UniqueWordCounter { public static char[] bytesToChars(byte[] bytes){ char[] result = new char[bytes.length >> 1]; for(int i = 0; i = 'A' && c = 'a' && c result = new HashMap(); long start = System.nanoTime(); char[] info = bytesToChars(Files.readAllBytes(path)); System.out.println(info); for(int i = 0, count = info.length; i < count; i++){ if(isLetter(info[i])){ char[] word = new char[32]; int k = 0; word[k] = info[i]; while(i < count - 1 && isLetter(info[i+1])){ word[++k] = info[++i]; } System.out.println(word); if(result.containsKey(word)) result.get(word).incrementAndGet(); else result.put(word,new AtomicInteger(1)); } } long elapsedTime = System.currentTimeMillis() - start; out.write(path.toAbsolutePath() + "\n"); for(String word: result.keySet()) out.write(word + " = " + result.get(word) + " occurrences\n"); out.write("Total unique words = "+result.keySet().size()+" - it takes "+ elapsedTime+ "ns\n"); out.flush(); } }