MeetCode
Derangements Small
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Derangements Small
Hard
Computer Mathematics
Combinatorics
33 views
Explanation
Complexity
Problem Statement
Compute number of derangements for n
Input Format
One integer n.
Output Format
One integer.
Example
Input
4
Output
9
Constraints
0
Input / Output Format
Input Format
One integer n.
Output Format
One integer.
Constraints
0
Examples
Input:
4
Output:
9
Example Solution (Public)
Computer Mathematics
Use recurrence D(0)=1,D(1)=0,D(n)=(n-1)*(D(n-1)+D(n-2)).
Official Solution Code
Wrap
Copy
Use recurrence D(0)=1,D(1)=0,D(n)=(n-1)*(D(n-1)+D(n-2)).
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
4
Expected Output
9
Compile Output
Error
Output
Please
login
to submit solutions.