← Microsoft questions

Find min and max in array with optimized comparisons

Filed under Microsoft

Given an array of n numbers, find both the minimum and maximum values using the minimum number of comparisons (fewer than 2(n - 1)). Return the result as a tuple (min_val, max_val).

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 Microsoft questions

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