Listing all permutations of a string/integer

后端 未结 29 2520
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 00:44

A common task in programming interviews (not from my experience of interviews though) is to take a string or an integer and list every possible permutation.

Is there

29条回答
  •  执笔经年
    2020-11-22 01:27

    Here's a good article covering three algorithms for finding all permutations, including one to find the next permutation.

    http://www.cut-the-knot.org/do_you_know/AllPerm.shtml

    C++ and Python have built-in next_permutation and itertools.permutations functions respectively.

提交回复
热议问题