Skip to content

Commit d410b4b

Browse files
authored
Update MonotonicStack.cs
1 parent 17cc566 commit d410b4b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

patterns/c#/MonotonicStack.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public class MonotonicStack {
55
public int[] NextGreaterElement(int[] nums) {
66
int n = nums.Length;
77
int[] result = new int[n];
8+
89
Array.Fill(result, -1); // Default to -1 if no greater element exists
910
Stack<int> stack = new Stack<int>(); // Stack stores indices
1011

@@ -32,4 +33,4 @@ public int[] DailyTemperatures(int[] temperatures) {
3233
}
3334
return result;
3435
}
35-
}
36+
}

0 commit comments

Comments
 (0)