Pergunta de entrevista da empresa Yandex

Write O(n) time algorithm that will find if there exists a permutation of characters for a given string such that it becomes a palindrome. You may assume that input string has no whitespace characters.

Resposta da entrevista

Sigiloso

30 de mar. de 2016

You can count all occurences of each letter in the string and store results in a hashmap for example. Then you loop through the hashmap and count how much odd numbers are there in the hashmap. If number of odds > 1 then the input string can't become a palindrome no matter how you toss around it's letters.