Pergunta de entrevista da empresa Meta

Find the first letter in a string that does not have a pair.

Respostas da entrevista

Sigiloso

12 de nov. de 2012

#include char getFirstNonRepChar(std::string& input) { int str_Len = input.length(); // Build a Hash Map Table std::map char_map; for(int i=0; i(input[i],1)); } for(int i=0; i< str_Len; i++) { if(char_map[input[i]] == 1) return input[i]; } } int main() { std::string input = "teeter"; char result = getFirstNonRepChar(input); std::cout << result <

1

Sigiloso

1 de jun. de 2009

Create a histogram and do a two time pass.

Sigiloso

21 de fev. de 2010

function findSingle($str) { $arr = str_split($str); foreach ($arr as $char) { if (1 == substr_count($str, $char)) { echo "first letter that doesnt have a pair: " . $char . "\n"; return; } } echo "no such letter\n"; } findSingle("lala"); findSingle("lalas");

1