← Cognizant questions
CodingReported in a candidate post, Sep 2024

Find largest and second-largest numbers in an array

Filed under Cognizant

Given an array of integers, find both the largest and the second-largest elements. The solution should ideally traverse the array only once (O(N) time complexity).

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Cognizant questions

Collected from public candidate posts and coding forums. Updated Nov 2026.