#Python Program to find Second Largest number in List with Sort
#/usr/bin/python3
n = int(input())
if ( n >= 2 and n <= 10):
lst = set(list(map(int,input().split()))) #Set's will avoid duplicated
new_lst = list(lst)
new_lst.sort()
print(new_lst[-2])
# Python Program to find Second Largest number in List Without Sort
#/usr/bin/python3
# Python Program to find Second Largest number in List Without Sort
#/usr/bin/python3
n = int(input())
a = list(map(int,input().split()))
f_num = a[0]
s_num = 0;
for i in range(1,n):
if(f_num > a[i] and a[i] > s_num) :
s_num = a[i]
if(a[i] > f_num):
s_num = f_num;
f_num = a[i]
print("Second Large number is :-",s_num)
Input - 5
5 2 10 1 2
Output -
Second Large number is :- 5
5 2 10 1 2
Output -
Second Large number is :- 5
Comments