Tap here to switch tabs
Problem
Submissions

Problem: Find the Derangement of An Array

Try to solve the Find the Derangement of An Array problem.

Statement

A derangement is defined as a permutation of an array such that no element appears in its original position.

Given an integer n representing an array initially containing n distinct elements from 11 to n, return the total number of derangements of the array.

Since the answer may be large, return the result modulo 109+710^9 + 7.

Constraints:

  • 1≤‘n‘≤1061 \leq `n` \leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Derangement of An Array

Try to solve the Find the Derangement of An Array problem.

Statement

A derangement is defined as a permutation of an array such that no element appears in its original position.

Given an integer n representing an array initially containing n distinct elements from 11 to n, return the total number of derangements of the array.

Since the answer may be large, return the result modulo 109+710^9 + 7.

Constraints:

  • 1≤‘n‘≤1061 \leq `n` \leq 10^6