diff --git a/solution/1500-1599/1535.Find the Winner of an Array Game/README.md b/solution/1500-1599/1535.Find the Winner of an Array Game/README.md index 7da5b58a0606b..d00eef2d4d1ed 100644 --- a/solution/1500-1599/1535.Find the Winner of an Array Game/README.md +++ b/solution/1500-1599/1535.Find the Winner of an Array Game/README.md @@ -175,6 +175,28 @@ function getWinner(arr: number[], k: number): number { } ``` +### **C#** + +```cs +public class Solution { + public int GetWinner(int[] arr, int k) { + int maxElement = arr[0], count = 0; + for (int i = 1; i < arr.Length; i++) { + if (maxElement < arr[i]) { + maxElement = arr[i]; + count = 1; + } else { + count++; + } + if (count == k) { + break; + } + } + return maxElement; + } +} +``` + ### **...** ``` diff --git a/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md b/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md index dabc098f0d949..c693ac6433995 100644 --- a/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md +++ b/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md @@ -153,6 +153,28 @@ function getWinner(arr: number[], k: number): number { } ``` +### **C#** + +```cs +public class Solution { + public int GetWinner(int[] arr, int k) { + int maxElement = arr[0], count = 0; + for (int i = 1; i < arr.Length; i++) { + if (maxElement < arr[i]) { + maxElement = arr[i]; + count = 1; + } else { + count++; + } + if (count == k) { + break; + } + } + return maxElement; + } +} +``` + ### **...** ```