2 parents bb76af3 + 46b82fa commit 2b8b65aCopy full SHA for 2b8b65a
1 file changed
data_structures/Stacks/next.py
@@ -0,0 +1,16 @@
1
+# Function to print element and NGE pair for all elements of list
2
+def printNGE(arr):
3
+
4
+ for i in range(0, len(arr), 1):
5
6
+ next = -1
7
+ for j in range(i+1, len(arr), 1):
8
+ if arr[i] < arr[j]:
9
+ next = arr[j]
10
+ break
11
12
+ print(str(arr[i]) + " -- " + str(next))
13
14
+# Driver program to test above function
15
+arr = [11,13,21,3]
16
+printNGE(arr)
0 commit comments