Skip to content

Commit 174ccde

Browse files
committed
list 2
1 parent 9fb00f6 commit 174ccde

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

hackerrank/python/second_largest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# my approach
2+
'''
3+
if __name__ == '__main__':
4+
n = int(input())
5+
#arr = map(int, input().split())
6+
7+
arr = [ int(x) for x in input().split() ]
8+
arr.sort(reverse=True)
9+
10+
i=0
11+
while arr[i] == arr[i+1]:
12+
i=i+1
13+
14+
print(arr[i+1])
15+
16+
'''
17+
18+
# elegant and short
19+
'''
20+
if __name__ == '__main__':
21+
n = int(input())
22+
arr = map(int, input().split())
23+
print(sorted(list(set(arr)))[-2])
24+
'''
25+
26+
27+
# without set and sort
28+
'''
29+
i = int(input())
30+
lis = list(map(int,raw_input().strip().split()))
31+
z = max(lis)
32+
while max(lis) == z:
33+
lis.remove(max(lis))
34+
35+
print max(lis)
36+
'''
37+

0 commit comments

Comments
 (0)