for (int i = 0; i < digits.length(); ++i) { string letters = letterC[digits[i] - '0']; int len = result.size(); for (int j = 0; j < len; ++j) { string str = result[0]; for (int k = 0; k < letters.length(); ++k) { string temp = str + letters[k]; result.push_back(temp); } result.erase(result.begin()); } } return result; } };
intmain(){ vector<string> result; result = Solution().letterCombinations("23"); // ad ae af bd be bf cd ce cf for (int i = 0; i < result.size(); ++i) { std::cout << result[i] << " "; } std::cout << std::endl; }