We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9fb00f6 commit 174ccdeCopy full SHA for 174ccde
hackerrank/python/second_largest.py
@@ -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
21
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