How to generate all variations with repetitions of a string?

前端 未结 3 433
南方客
南方客 2020-12-16 06:04

I want to generate all variations with repetitions of a string in C++ and I\'d highly prefer a non-recursive algorithm. I\'ve come up with a recursive algorithm in the past

3条回答
  •  暖寄归人
    2020-12-16 06:28

    here is general recipe, not C++ specific to implement product:

    Take product input string "abc.." to generate matrix "abc.."x"abc..". N^2 complexity. represent matrix as vector and repeat multiplication by "abc", complexity (N^2)*N, repeat.

提交回复
热议问题