Skip to content

Commit fbd3758

Browse files
committed
Time: 7 ms (98.89%), Space: 31.9 MB (52.78%) - LeetHub
1 parent ff185c8 commit fbd3758

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# time complexity: O(n)
2+
# space complexity: O(1)
3+
from typing import List
4+
5+
6+
class Solution:
7+
def countPermutations(self, complexity: List[int]) -> int:
8+
MOD = 10 ** 9 + 7
9+
n = len(complexity)
10+
base = complexity[0]
11+
for i in range(1, n):
12+
if complexity[i] <= base:
13+
return 0
14+
15+
result = 1
16+
for i in range(2, n):
17+
result = result * i % MOD
18+
return result
19+
20+
21+
complexity = [1, 2, 3]
22+
print(Solution().countPermutations(complexity))
23+
complexity = [3, 3, 3, 4, 4, 4]
24+
print(Solution().countPermutations(complexity))

0 commit comments

Comments
 (0)