Description
Give a string, you can choose to split the string after one character or two adjacent characters, and make the string to be composed of only one character or two characters. Output all possible results.
Example
Example1
Input: "123"
Output: [["1","2","3"],["12","3"],["1","23"]]
Example2
Input: "12345"
Output: [["1","23","45"],["12","3","45"],["12","34","5"],["1","2","3","45"],["1","2","34","5"],["1","23","4","5"],["12","3","4","5"],["1","2","3","4","5"]]
思路:
此题的思路跟其他题不一样,因为每次只要循环2个数,然后将string的范围缩小,最开始的时候我在string范围内循环,就得到了很多不想要的结果,对我来说还是比较难的。
代码:
网友评论