Skip to content

Practice Count the Number of Computer Unlocking Permutations

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3577
LeetCode Problem

Count the Number of Computer Unlocking Permutations

Problem Statement

Computer 0 is the initially unlocked root. To unlock computer i, a previously unlocked computer j must satisfy both j < i and complexity[j] < complexity[i]. Count the valid permutations of all computer labels representing the unlocking order, beginning with root 0, and return the count modulo 10^9 + 7. The initially unlocked password belongs specifically to label 0, not an arbitrary first computer.

Source: Count the Number of Computer Unlocking Permutations on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
complexity = [1,2,3]
Output
2

# Example 2

Input
complexity = [3,3,3,4,4,4]
Output
0

Constraints

2 <= complexity.length <= 10^5
1 <= complexity[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Count the Number of Computer Unlocking Permutations.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.