1
cosmic 2023-07-19 03:50:29 +08:00 1
```
def getAllCombinations(num): s = str(num) n = len(s) @lru_cache(None) def dfs(idx): if idx == n: return [[]] ans = [] if s[idx] != "0": for i in range(idx, n): t = int(s[idx:i+1]) tmp = dfs(i + 1) for j in tmp: ans.append([t] + j) return ans return dfs(0) ``` |
2
cosmic 2023-07-19 03:51:15 +08:00 1
|
3
cosmic 2023-07-19 04:00:09 +08:00 1
第一个回复漏了不大于 26 的条件,而且 V 站的格式也有问题,更新了解法在第二个回复的链接里
|