We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3ec7a5 commit 8865ed8Copy full SHA for 8865ed8
problems/0941.有效的山脉数组.md
@@ -177,7 +177,24 @@ function validMountainArray(arr: number[]): boolean {
177
};
178
```
179
180
+## C#
181
182
+```csharp
183
+public class Solution {
184
+ public bool ValidMountainArray(int[] arr) {
185
+ if (arr.Length < 3) return false;
186
+
187
+ int left = 0;
188
+ int right = arr.Length - 1;
189
190
+ while (left + 1< arr.Length && arr[left] < arr[left + 1]) left ++;
191
+ while (right > 0 && arr[right] < arr[right - 1]) right --;
192
+ if (left == right && left != 0 && right != arr.Length - 1) return true;
193
194
+ return false;
195
+ }
196
+}
197
+```
198
199
200
-----------------------
0 commit comments