← Microsoft questions

Maximize number by swapping two elements or bits

Filed under Microsoft

Given an array of 0s and 1s, write code to swap only two elements so that the resulting number formed by keeping elements in the same order is maximized. Adaptable to swapping bits in a number…

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.