How to find second largest no. in an array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to find second largest no. in an array?

in c++

27th Aug 2017, 7:14 PM
Sourabh
3 Answers
+ 5
If it contains unique values only: print(sorted(list_name)[-2])
27th Aug 2017, 7:20 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
Sort it and pick the 2nd element. Simple.
28th Aug 2017, 12:18 AM
Haris
Haris - avatar