Pergunta da entrevista

Entrevista para IOS Developer

-Karlsruhe, Baden-Wurttemberg


Write a program to find second largest no in given array.


Respostas da entrevista

2 respostas


How about sorting the array and move 2 indices from the last item and get the value. This way, we can extend the solution to finding the k-th largest element in an array.

Pradeep em


In an unsorted array whenever you set the largest number during iteration, you set second largest number to previous largest number.

Ihtesham Khan em

Adicionar respostas ou comentários

Para comentar sobre isso, entre na conta ou cadastre-se.