So I'm working on a little project and I want to write a method that computes the total possible unique permutations of a char[]
. The formula for this would be
n!/ possible duplicates
Meaning if I had the word toffee it would be
6!/(2!*2!)
As there are 6 letters total, and 2 duplicate letters that each show up twice.
My first issue is there doesn't seem to be a standard method for computing factorials. Also, the only way I can think of to figure out the possible duplicates, is to scan the whole array and keep track of how many times each letter shows up. Is there a better/more efficient way to do this? All I simply need as a return is a number of total possible unique permutations.