美文网首页
680. Split String

680. Split String

作者: 鸭蛋蛋_8441 | 来源:发表于2019-06-28 12:44 被阅读0次

    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范围内循环,就得到了很多不想要的结果,对我来说还是比较难的。

    代码:

    相关文章

      网友评论

          本文标题:680. Split String

          本文链接:https://www.haomeiwen.com/subject/ljyscctx.html