Sollicitatievraag bij Crest Data Systems

Find the second largest element in an array?

Antwoord op sollicitatievraag

Anoniem

27 feb 2024

Keep largest and secondLargest iterate over the array and whenever you find an element greater than largest update secondLargest to largest and largest to current element or if the element is smaller than largest but greater than secondLargest simply update secondLargest to current element.