Given a batch of part numbers, reorder them so all even-numbered parts come first, followed by odd-numbered parts.
Explanation: Step 1: Separate even and odd numbers. Even numbers: [2, 4, 6, 8, 10]. Odd numbers: [5, 9, 7, 3, 1]. Step 2: Sort the even numbers in ascending order: [2, 4, 6, 8, 10]. Step 3: Sort the odd numbers in ascending order: [1, 3, 5, 7, 9]. Step 4: Combine the sorted even and odd numbers: [2, 6, 4, 8, 10, 5, 9, 7, 3, 1].
Explanation: Step 1: Separate even and odd numbers. Even numbers: [4, 10, 6, 8, 2]. Odd numbers: [7, 1, 3, 9, 5]. Step 2: Sort the even numbers in ascending order: [2, 4, 6, 8, 10]. Step 3: Sort the odd numbers in ascending order: [1, 3, 5, 7, 9]. Step 4: Combine the sorted even and odd numbers: [2, 4, 6, 8, 10, 1, 3, 7, 9, 5].
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak