Find the Runner-Up Score!

Sort by

recency

|

8433 Discussions

|

  • + 0 comments

    if name == 'main': n = int(input()) arr = map(int, input().split())

    runner_up = sorted(set(arr))
    print(runner_up[-2])

    """" set(arr) → removes duplicate scores (like multiple 6’s). sorted(...) → sorts the unique scores in ascending order. sorted_arr[-2] → accesses the second last (runner-up) element. """"

  • + 0 comments

    if name == 'main': rev = set() n = int(input()) arr = list(map(int, input().split())) rev = set(arr) arr=list(rev) arr.sort(reverse=True) print(arr[1])

  • + 0 comments

    if name == 'main': n = int(input()) arr = map(int, input().split())

        sorted_list= sorted(set(arr))
        print(sorted_list[-2])
    
  • + 0 comments
    if __name__ == '__main__':
        n = int(input())
        arr = list(map(int, input().split()))
        
        unique_scores = set(arr)
        runner_up = sorted(unique_scores, reverse=True)[1]
        print(runner_up)
    
  • + 0 comments

    #find the second hight score number #print it out

    #First do list of all of elements
    arr = list(arr)
    arr.sort()
    #print(arr)
    
    #remove duplicates
    uniuque_elements = set(arr)
    #print(uniuque_elements)
    
    #find the second hight score number
    max_value = max(uniuque_elements)
    
    uniuque_elements.remove(max_value)
    #print(uniuque_elements)
    

    Something I got confused about while working on this problem was actually understanding what the term "runner-up score" means. This was a bit confusing for me. The second thing I wasn't sure about was how to create a list for the "arr." However, in the end, I understood that we do need to have a list. But did we convert the "arr" to a list?

    print(max(uniuque_elements))