employer cover photo
employer logo
employer logo

Hortonworks

Acquired by Cloudera

Is this your company?

Hortonworks Interview Question

Write a program to count words in a string?

Interview Answer

Anonymous

Jul 8, 2018

void countWords(String text) { Map wordCount = new HashMap(); List words = Arrays.asList(text.split(" ")); for (String word : words) { if (wordCount.containsKey(word)) { wordCount.put(word, wordCount.get(word) + 1); } else { wordCount.put(word, 1); } } }