SAS interview question

Swap two integers until you cannot.

Interview Answer

Anonymous

10 Oct 2025

use a for loop and compare the current element to element to right (-1) to avoid out of bounds, and use a while loop to do this to check with a boolean flag. Time Complexity is N ^ 2. I offered to optimize, but the interviewer declined.