Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.
Input:Digit string "23"Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
Note:
Although the above answer is in lexicographical order, your answer could be in any order you want.这道题看起来十分弱小,吃掉它
class Solution {public: vectorletterCombinations(string digits) { // Start typing your C/C++ solution below // DO NOT write int main() function vector ret; if(digits.length()==0){ ret.push_back(""); return ret; } map m; m['2']="abc"; m['3']="def"; m['4']="ghi"; m['5']="jkl"; m['6']="mno"; m['7']="pqrs"; m['8']="tuv"; m['9']="wxyz"; m['0']=" "; m['*']="+"; vector ptr; ptr.resize(digits.length()); for(int i=0;i =digits.length()){ ret.push_back(rs); i--; rs.resize(i); } else{ ptr[i]=0; } } } return ret; }};