Salesforce | Virtual Interview | SDE-1 | India
Anonymous User
1971

This was the first round of virtual interview after the OA. Given a list of integers, reorder them in such a way that the even numbers come at even positions (0-based indexing), and the odd numbers come at odd position, with their relative order being the same as in the original list. If the number of even numbers is greater than odd numbers (or vice-versa), the extra ones should be at the end.

[42, 24, 64, 83, 12, 6, 21, 55] --> [42, 83, 24, 21, 64, 55, 12, 6]

The interviewer expected a solution with O(n) time complexity and O(1) extra space. Could not think of such a solution and received a rejection call within an hour.

Comments (8)