Skip to content

Commit eadf3f9

Browse files
refactor 320
1 parent 169d1c1 commit eadf3f9

File tree

1 file changed

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

1 file changed

+2
-12
lines changed

src/main/java/com/fishercoder/solutions/_320.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
/**
7-
* 320. Generalized Abbreviation
8-
*
9-
* Write a function to generate the generalized abbreviations of a word.
10-
11-
Example:
12-
13-
Given word = "word", return the following list (order does not matter):
14-
["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
15-
*/
166
public class _320 {
177

188
public static class Solution1 {
@@ -23,7 +13,7 @@ public List<String> generateAbbreviations(String word) {
2313
}
2414

2515
private void backtrack(String word, List<String> result, int position, String current,
26-
int count) {
16+
int count) {
2717
if (position == word.length()) {
2818
if (count > 0) {
2919
current += count;
@@ -32,7 +22,7 @@ private void backtrack(String word, List<String> result, int position, String cu
3222
} else {
3323
backtrack(word, result, position + 1, current, count + 1);
3424
backtrack(word, result, position + 1,
35-
current + (count > 0 ? count : "") + word.charAt(position), 0);
25+
current + (count > 0 ? count : "") + word.charAt(position), 0);
3626
}
3727
}
3828
}

0 commit comments

Comments
 (0)