标签:
感觉我的方法逻辑不够清晰
public class Solution { private List<String> result; public List<String> generateAbbreviations(String word) { result = new ArrayList<String>(); helper(word, -2, 0); result.add(word); return result; } public void helper(String word, int index, int l) { int length = word.length(); for (int i = index + 2 + l; i < length; i++) { for (int j = 1; j + i <= length; j++) { String str = word.substring(0, i) + String.valueOf(j) + word.substring(i + j); result.add(str); helper(str, i, String.valueOf(j).length() - 1); } } } }
[LeetCode]Generalized Abbreviation
标签:
原文地址:http://www.cnblogs.com/vision-love-programming/p/5097452.html