python find the 2nd highest element
Question: 1.In a given array how to find the 2nd or 3rd,4th ,5th values.

2.Also if we use max() function in python what is the order of complexity i.e,
associated with this function max()

    
    
     def nth_largest(li,n):   
        li.remove(max(li))
        print max(ele)  //will give me the second largest
        #how to make a general algorithm to find the 2nd,3rd,4th highest value
        #n is the element to be found  below the highest value
    


Answer: I'd go for:

    
    
    import heapq
    res = heapq.nlargest(2, some_sequence)
    print res[1] # to get 2nd largest
    

This is more efficient than sorting the entire list, then taking the first `n`
many elements. See the [heapq
documentation](http://docs.python.org/2/library/heapq.html) for further info.

