Pregunta de entrevista de Meta

Implement a suggestion function that generates alternative strings for given password strings like "facebook" => "F@ceß00k" and "fæc€Bo0K" or sth.

Respuestas de entrevistas

Anónimo

8 oct 2011

// Assumption is that we have two dictionaries populated // First dictionary is a conversion from all common symbols/chars, to a common base char // Second dictionary is all the related chars to the common base chars class Suggestor { Map BaseChars; Map CharGenerator; string suggest(string str) { for (int i=0;i

2

Anónimo

5 abr 2012

Overlapping sub-problems.. dynamic programming like approach.. vector gen_passwords(string pass, int indx, map m) { if(indx >= pass.size()) { return vector(); } string special = m[pass[indx]]; vector vec = gen_passwords(pass, indx+1, m); vector res; if(special == "") { if(vec.size() == 0) vec.push_back(""); for(int i = 0; i < vec.size(); i++) vec[i] = pass[indx]+vec[i]; return vec; } for(int i = 0; i < special.size(); i++) { for(int j = 0; j < vec.size(); j++) res.push_back(special[i]+vec[j]); } return res; }