File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
solution/0600-0699/0621.Task Scheduler Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,26 @@ func max(a, b int) int {
158
158
}
159
159
```
160
160
161
+ ### ** C#**
162
+
163
+ ``` cs
164
+ public class Solution {
165
+ public int LeastInterval (char [] tasks , int n ) {
166
+ int [] cnt = new int [26 ];
167
+ int x = 0 ;
168
+ foreach (char c in tasks ) {
169
+ cnt [c - 'A' ]++ ;
170
+ x = Math .Max (x , cnt [c - 'A' ]);
171
+ }
172
+ int s = 0 ;
173
+ foreach (int v in cnt ) {
174
+ s = v == x ? s + 1 : s ;
175
+ }
176
+ return Math .Max (tasks .Length , (x - 1 ) * (n + 1 ) + s );
177
+ }
178
+ }
179
+ ```
180
+
161
181
### ** ...**
162
182
163
183
```
Original file line number Diff line number Diff line change @@ -141,6 +141,26 @@ func max(a, b int) int {
141
141
}
142
142
```
143
143
144
+ ### ** C#**
145
+
146
+ ``` cs
147
+ public class Solution {
148
+ public int LeastInterval (char [] tasks , int n ) {
149
+ int [] cnt = new int [26 ];
150
+ int x = 0 ;
151
+ foreach (char c in tasks ) {
152
+ cnt [c - 'A' ]++ ;
153
+ x = Math .Max (x , cnt [c - 'A' ]);
154
+ }
155
+ int s = 0 ;
156
+ foreach (int v in cnt ) {
157
+ s = v == x ? s + 1 : s ;
158
+ }
159
+ return Math .Max (tasks .Length , (x - 1 ) * (n + 1 ) + s );
160
+ }
161
+ }
162
+ ```
163
+
144
164
### ** ...**
145
165
146
166
```
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public int LeastInterval ( char [ ] tasks , int n ) {
3
+ int [ ] cnt = new int [ 26 ] ;
4
+ int x = 0 ;
5
+ foreach ( char c in tasks ) {
6
+ cnt [ c - 'A' ] ++ ;
7
+ x = Math . Max ( x , cnt [ c - 'A' ] ) ;
8
+ }
9
+ int s = 0 ;
10
+ foreach ( int v in cnt ) {
11
+ s = v == x ? s + 1 : s ;
12
+ }
13
+ return Math . Max ( tasks . Length , ( x - 1 ) * ( n + 1 ) + s ) ;
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments