Pregunta de entrevista de Uber

Algorithm question of string and hash