Skip to content

Commit 15ef61d

Browse files
authored
feat: add csharp to lc problem: No.1535 (#1928)
1 parent 40cb6d7 commit 15ef61d

File tree

1 file changed

+17
-0
lines changed
  • solution/1500-1599/1535.Find the Winner of an Array Game

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Solution {
2+
public int GetWinner(int[] arr, int k) {
3+
int maxElement = arr[0], count = 0;
4+
for (int i = 1; i < arr.Length; i++) {
5+
if (maxElement < arr[i]) {
6+
maxElement = arr[i];
7+
count = 1;
8+
} else {
9+
count++;
10+
}
11+
if (count == k) {
12+
break;
13+
}
14+
}
15+
return maxElement;
16+
}
17+
}

0 commit comments

Comments
 (0)