Problems
Contests
Account
Problems
> Count the Derangements > Editorial
Count the Derangements — Solution & Editorial
Back to the Problem
Recurrence D
n
= (n−1)(D
n−1
+ D
n−2
) with D
0
= 1, D
1
= 0.
Complexity:
O(N)
×
Refer Job