public class Solution {
public List<String> generateAbbreviations(String word) {
List<String> rst = new ArrayList<>();
dfs(word, "", 0, 0, rst);
return rst;
}
private void dfs(String word, String cur, int pos, int count, List<String> rst) {
if (pos == word.length()) {
if (count > 0) cur += count;
rst.add(cur);
return;
}
dfs(word, cur, pos + 1, count + 1, rst);
dfs(word, cur + (count > 0 ? count : "") + word.charAt(pos), pos + 1, 0, rst);
}
}