There was an error while loading. Please reload this page.
1 parent 17cc566 commit d410b4bCopy full SHA for d410b4b
patterns/c#/MonotonicStack.cs
@@ -5,6 +5,7 @@ public class MonotonicStack {
5
public int[] NextGreaterElement(int[] nums) {
6
int n = nums.Length;
7
int[] result = new int[n];
8
+
9
Array.Fill(result, -1); // Default to -1 if no greater element exists
10
Stack<int> stack = new Stack<int>(); // Stack stores indices
11
@@ -32,4 +33,4 @@ public int[] DailyTemperatures(int[] temperatures) {
32
33
}
34
return result;
35
-}
36
+}
0 commit comments