Skip to content

Commit e15548a

Browse files
committed
feat: add csharp solution to lc problem: No.3577
1 parent 82a55ad commit e15548a

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,24 @@ impl Solution {
207207
}
208208
```
209209

210+
#### C#
211+
212+
```cs
213+
public class Solution {
214+
public int CountPermutations(int[] complexity) {
215+
const int mod = (int) 1e9 + 7;
216+
long ans = 1;
217+
for (int i = 1; i < complexity.Length; ++i) {
218+
if (complexity[i] <= complexity[0]) {
219+
return 0;
220+
}
221+
ans = ans * i % mod;
222+
}
223+
return (int) ans;
224+
}
225+
}
226+
```
227+
210228
<!-- tabs:end -->
211229

212230
<!-- solution:end -->

solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README_EN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,24 @@ impl Solution {
203203
}
204204
```
205205

206+
#### C#
207+
208+
```cs
209+
public class Solution {
210+
public int CountPermutations(int[] complexity) {
211+
const int mod = (int) 1e9 + 7;
212+
long ans = 1;
213+
for (int i = 1; i < complexity.Length; ++i) {
214+
if (complexity[i] <= complexity[0]) {
215+
return 0;
216+
}
217+
ans = ans * i % mod;
218+
}
219+
return (int) ans;
220+
}
221+
}
222+
```
223+
206224
<!-- tabs:end -->
207225

208226
<!-- solution:end -->
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class Solution {
2+
public int CountPermutations(int[] complexity) {
3+
const int mod = (int) 1e9 + 7;
4+
long ans = 1;
5+
for (int i = 1; i < complexity.Length; ++i) {
6+
if (complexity[i] <= complexity[0]) {
7+
return 0;
8+
}
9+
ans = ans * i % mod;
10+
}
11+
return (int) ans;
12+
}
13+
}

0 commit comments

Comments
 (0)