← Microsoft questions

Swap adjacent array elements

Filed under Microsoft

Given an array of integers, swap every pair of adjacent elements. For example, [1, 2, 3, 4, 5, 6] becomes [2, 1, 4, 3, 6, 5]. If the array has an odd number of elements, the last element should remain…

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.