Skip to content

Commit 62a57f8

Browse files
authoredNov 5, 2023
docs: update README_EN and README to lc problem: No.1535 (doocs#1929)
1 parent 15ef61d commit 62a57f8

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
 

Diff for: ‎solution/1500-1599/1535.Find the Winner of an Array Game/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,28 @@ function getWinner(arr: number[], k: number): number {
175175
}
176176
```
177177

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+
178200
### **...**
179201

180202
```

Diff for: ‎solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md

+22
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,28 @@ function getWinner(arr: number[], k: number): number {
153153
}
154154
```
155155

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+
156178
### **...**
157179

158180
```

0 commit comments

Comments
 (0)