Question d’entretien chez Innominds Software

Write program for 2nd largest number without using inbuilt function and without more than 1 loop?

Réponses aux questions d'entretien

Utilisateur anonyme

13 mai 2022

import sys a=[int(x) for x in input().split()] #To take all user inputs max1=a[0] max2= -sys.maxsize # to initialize max2 as minimum #oly one loop for i in a: if i > max1: max1,max2 = i,max1 if i max2: max2 = i print(max2)

Utilisateur anonyme

13 mai 2022

#WHY THE HELL THIS COMMENT BOX DELETES MY INDENTATION ?? LOL # JUST DELETE THOSE "----" and add tab for indentation, apologies... import sys a=[int(x) for x in input().split()] max1=a[0] max2= -sys.maxsize for i in a: ----if i > max1: --------max1,max2 = i,max1 ----if i max2: --------max2 = i print(max2)