Pergunta de entrevista da empresa Microsoft

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

Respostas da entrevista

Sigiloso

27 de set. de 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

Sigiloso

6 de out. de 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 }