Intermediate Level
Implement the permutationsCountDistinct method that counts distinct permutations of the given values.
The input array nums contains size distinct values.
Your task is to return how many different permutations can be created using all values from the array. A permutation is an ordering of all elements.
For example, [1,2,3] has 6 permutations because the three values can be arranged in 3 × 2 × 1 ways.
For distinct values, the number of permutations is the factorial of the array size.
There are size choices for the first position, then size - 1 choices for the second position, and so on until only one value remains.
Multiply all numbers from 1 to size to get the total permutation count.
Pseudocode:
function permutationsCountDistinct(nums, size):
result = 1
for i from 2 to size:
result = result * i
return result