Microsoft Interview Question

Given a string, say the most repeated letter in the string

Interview Answers

Anonymous

Sep 27, 2014

Use a hash function with the key as a char and value as an int. Iterate over the string and ++ the int in the hash for each letter.

2

Anonymous

Oct 6, 2014

public char mostRepeated(String s) { int[] myChars = new char[128]; // assuming ascii for(int i = 0; i indexWithHighest) { indexWithHighest = i; } } return indexWithHighest; // basic solution. better just keeps track of highest index throughout }