Permutations of capitalization

前端 未结 8 651
生来不讨喜
生来不讨喜 2020-12-21 01:24

I want to build a list containing every possible permutation of capitalization of a word. so it would be

List permutate(string word)
{
    List         


        
8条回答
  •  抹茶落季
    2020-12-21 01:58

    Keep in mind that while the accepted answer is the most straightforward way of capitalizing an arbitrary letter, if you are going to change the capitalization repeatedly on the same set of letters (e.g., 32 times in "happy" and growing exponentially for longer words), it will be more efficient to turn the string into a char[], set the appropriate letter(s), and construct the string from the array.

提交回复
热议问题