0
Find second Largest number in a list.
find second largest number in a list, would be very easy if we use Max and sort. But finding it without using built-in functions, also a catch which makes the problem interesting is that u can iterate over the list only once. Have tried it, but failed at iterating over the list once. Any other approaches..Thanks https://code.sololearn.com/cm2t5tscw58z/?ref=app
2 odpowiedzi
+ 1
you could do two variables to store highest and second highest and do if statements that compares if its higher that highest and higher than second highest in the stored variables.
and if the iterated element is higher than one of them, replace the variable value(s).
0
Saumya Katiyar cannot do it iterating only once, but can do it iterating twice through the list.I think its not possible to solve by iterating it only once but I am not sure.