Loading…
Loading…
Given an array of distinct integers, return the count of all possible orderings.
Input: 1 2 3
Output: 6
At each step, pick any one of the still-unused numbers next, recurse on the rest, and count a complete permutation once every number has been placed. This branches into exactly n! leaves.
Line 1: the array, space-separated
Print the total number of permutations.
Input (stdin)
Output
Input (stdin)
Output
Sign in to track solved problems and earn XP.