Friday, February 1, 2019

Searching - 2

  • Problem Description

    Given an array of distinct elements, sort the elements and find the third largest element in it.

    Take the number of elements and the array as input.
  • CODING ARENA
  • a=int(input())
    x=[]
    for i in range(a):
        b=int(input())
        x.append(b)
    x.sort()
    print(x[2])
  • Test Case 1

    Input (stdin)
    5
    
    90
    
    80
    
    70
    
    60
    
    50
    
    
    Expected Output
    70
  • Test Case 2

    Input (stdin)
    6
    
    90
    
    90
    
    90
    
    20
    
    10
    
    0
    
    
    Expected Output
    20

No comments:

Post a Comment