Not a member of GistPad yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- List<String> result = new ArrayList<>();
- if(digits.length() == 0)
- return result;
- map.put(0, "");
- map.put(1, "");
- map.put(2, "abc");
- map.put(3, "def");
- map.put(4, "ghi");
- map.put(5, "jkl");
- map.put(6, "mno");
- map.put(7, "pqrs");
- map.put(8, "tuv");
- map.put(9, "wxyz");
- findCombination(digits, 0, str, result, map);
- return result;
- }
- {
- if(index == digits.length())
- {
- result.add(str);
- return;
- }
- char digitChar = digits.charAt(index);
- int digit = digitChar - '0';
- for(char ch : value.toCharArray())
- {
- findCombination(digits, index+1, str + ch, result, map);
- }
- }
- }
- // digits = "34"
- // digitChar = '3' map.get('3')="def"
RAW Paste Data
Copied
