Algorithm to generate all combinations of a string

前端 未结 10 1952
日久生厌
日久生厌 2021-02-01 22:47

I found a link online that shows an algorithm to generate all combinations of a string: http://www.mytechinterviews.com/combinations-of-a-string

Algorithm is copied belo

10条回答
  •  长情又很酷
    2021-02-01 23:12

    The call of outstr.deleteCharAt counters the effect of outstr.append by deleting the last character of the outstr.

    Each loop iteration proceeds as follows:

    1. append a character
    2. print the result
    3. perform a recursive invocation at the level i+1
    4. remove the character we added at step 1

提交回复
热议问题