Merge pull request #143 from rajnishyadav321/patch-1

Added Next Greater Element
This commit is contained in:
Harshil 2017-10-18 11:11:10 +05:30 committed by GitHub
commit 2b8b65a445

View File

@ -0,0 +1,16 @@
# Function to print element and NGE pair for all elements of list
def printNGE(arr):
for i in range(0, len(arr), 1):
next = -1
for j in range(i+1, len(arr), 1):
if arr[i] < arr[j]:
next = arr[j]
break
print(str(arr[i]) + " -- " + str(next))
# Driver program to test above function
arr = [11,13,21,3]
printNGE(arr)