Partition and Group Values by Parity
Updated
Problem statement
Given an integer array nums, return two groups: all even values in their original order, followed by all odd values in their original order.
The result must always contain exactly two rows. Either row may be empty.
Function
partitionByParity(nums: int[]) → int[][]Examples
Example 1
nums = [3,2,4,1,0]return = [[2,4,0],[3,1]]The first row contains stable evens and the second contains stable odds.
Example 2
nums = [2,4]return = [[2,4],[]]The odd group is empty.
Constraints
0 <= nums.length <= 100000.-10^9 <= nums[i] <= 10^9.
Source note: Author-written prompt excerpt retained for source fidelity.
More EPAM Phone Screen questions
- Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
- Container With Most WaterPHONE SCREEN · Seen Oct 2026
- Convert an Entry List to a MapPHONE SCREEN · Seen Oct 2026
- Count Array Element FrequenciesPHONE SCREEN · Seen Oct 2026
- Find First and Last Position of Element in Sorted ArrayPHONE SCREEN · Seen Oct 2026
- Group AnagramsPHONE SCREEN · Seen Oct 2026
- Longest Consecutive SequencePHONE SCREEN · Seen Oct 2026
- Max Consecutive Ones IIIPHONE SCREEN · Seen Oct 2026
- Minimum Currency ConversionsPHONE SCREEN · Seen Oct 2026
- Next Greater Element IPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
- Paginate Retained Conversation HistorySierra · PHONE SCREENSierra interview questions
- Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Bounded IPv4 FilterAmazon · PHONE SCREEN