public class Solution {
public IList<string> LetterCombinations(string digits) {
Dictionary<char, char[]> phone = new Dictionary<char,char[]>(){
{'2', new char[]{'a','b','c'}},
{'3',new char[]{'d','e','f'}},
{'4',new char[]{'g','h','i'}},
{'5',new char[]{'j','k','l'}},
{'6',new char[]{'m','n','o'}},
{'7',new char[]{'p','q','r','s'}},
{'8',new char[]{'t','u','v'}},
{'9',new char[]{'w','x','y','z'}}};
List<string> combinations = new List<string>();
int length = digits.Length;
if(digits == null || length == 0) return combinations;
for(int i = 0; i < length; i++){
if(length == 1){
foreach (var letter in phone[digits[i]])
{
combinations.Add(letter.ToString());
}
}
for(int k = 0 ; k < length - 1; k++){
for(int j = 0 + k; j < length - 1; j++){
int z = 0;
combinations.add( phone[digits[k][z]] += phone[digits[j][z]]);
z++
if(z == 2) break;
}
}
}
return combinations;
}
}