Given an array, print the largest contiguous element (MEC) for each element. The largest contiguous element (MEC) for an element x is the first largest element on the right of x in an array. The elements for which the largest contiguous element does not exist, assign as a greater element the value -1.
Use these examples:
For the input array [4, 5, 2, 25], the largest contiguous elements for each element are the following:
Elemento MEC 4 --> 5; 5 --> 25; 2 --> 25; 25 --> -1;
For the input arrangement [13,7,6,12], the largest contiguous elements for each element are the following:
Elemento MEC 13 --> -1; 7 --> 12; 6 --> 12; 12 --> -1;
Your solution should be delivered using two methods:
I have this:
lista = [4, 5, 2, 25]
print "Los valores de la lista son: ",lista
n=input("Busque el elemento contiguo de la lista: ")
a=lista[0]
b=lista[1]
c=lista[2]
d=lista[3]
if n==a:
if a<b:
print"Contiguo de: ",n," es: ", b
if n==b:
if b<c:
print"Contiguo de: ",n," es: ", c
else: