Skip to content

Commit 48a6112

Browse files
update 17
1 parent 1e2c014 commit 48a6112

File tree

1 file changed

+2
-1
lines changed
  • src/main/java/com/fishercoder/solutions/firstthousand

1 file changed

+2
-1
lines changed

src/main/java/com/fishercoder/solutions/firstthousand/_17.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ List<String> combine(String letters, List<String> result) {
3737

3838
public static class Solution2 {
3939
/**
40+
* It's recommended to use recursion to solve this problem, I got this feedback from a Meta interviewer on 6/17/2024 during the mock interview.
4041
* My completely original solution on 10/11/2021, no backtracking involved.
4142
*/
4243
public List<String> letterCombinations(String digits) {
@@ -54,7 +55,7 @@ private List<String> recursion(List<String> ans, String[] options, String digits
5455
return ans;
5556
}
5657
List<String> newAns = new ArrayList<>();
57-
String candidates = options[Integer.parseInt(digits.charAt(index) + "")];
58+
String candidates = options[digits.charAt(index) - '0'];
5859
for (String str : ans) {
5960
for (int i = 0; i < candidates.length(); i++) {
6061
newAns.add(str + candidates.charAt(i));

0 commit comments

Comments
 (0)