File tree 2 files changed +44
-0
lines changed
solution/1500-1599/1535.Find the Winner of an Array Game
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,28 @@ function getWinner(arr: number[], k: number): number {
175
175
}
176
176
```
177
177
178
+ ### ** C#**
179
+
180
+ ``` cs
181
+ public class Solution {
182
+ public int GetWinner (int [] arr , int k ) {
183
+ int maxElement = arr [0 ], count = 0 ;
184
+ for (int i = 1 ; i < arr .Length ; i ++ ) {
185
+ if (maxElement < arr [i ]) {
186
+ maxElement = arr [i ];
187
+ count = 1 ;
188
+ } else {
189
+ count ++ ;
190
+ }
191
+ if (count == k ) {
192
+ break ;
193
+ }
194
+ }
195
+ return maxElement ;
196
+ }
197
+ }
198
+ ```
199
+
178
200
### ** ...**
179
201
180
202
```
Original file line number Diff line number Diff line change @@ -153,6 +153,28 @@ function getWinner(arr: number[], k: number): number {
153
153
}
154
154
```
155
155
156
+ ### ** C#**
157
+
158
+ ``` cs
159
+ public class Solution {
160
+ public int GetWinner (int [] arr , int k ) {
161
+ int maxElement = arr [0 ], count = 0 ;
162
+ for (int i = 1 ; i < arr .Length ; i ++ ) {
163
+ if (maxElement < arr [i ]) {
164
+ maxElement = arr [i ];
165
+ count = 1 ;
166
+ } else {
167
+ count ++ ;
168
+ }
169
+ if (count == k ) {
170
+ break ;
171
+ }
172
+ }
173
+ return maxElement ;
174
+ }
175
+ }
176
+ ```
177
+
156
178
### ** ...**
157
179
158
180
```
You can’t perform that action at this time.
0 commit comments