Find the Runner-Up Score!

Sort by

recency

|

8192 Discussions

|

  • + 0 comments

    sc = list(set(arr)) sc.sort(reverse=True) print(sc[1])

  • + 0 comments

    This is what I came up with.

    if __name__ == '__main__':
        n = int(input())
        arr = map(int, input().split())
        
        lst_scores = sorted(list(arr), reverse=True)
    
        for i in range(1, n): # we can skip the position 0 as that is the max since list is sorted in desc order
            if lst_scores[i] < lst_scores[0]: # lst_scores[0] is max
                v_runner_up = lst_scores[i] # if the above condition is true then we set the v_runner_up to the 2nd highest
                break
        print(v_runner_up)
    
  • + 0 comments

    Haha this works...must be a bug.

    if __name__ == '__main__':
        n = int(input())
        arr = map(int, input().split())
        
    print(n)
    
  • + 0 comments

    a=sorted(set(list(arr))) print(a[-2])

  • + 0 comments

    print (sorted(set(list(arr)), reverse=True)[1])