EASYasked at 1 company

Sort Array By Parity

A easy-tier problem at 76% community acceptance, tagged with Array, Two Pointers, Sorting. Reported in interviews at DXC Technology and 0 others.

Founder's read

Sort Array By Parity is a straightforward array problem that shows up in early-round screens, including at DXC Technology. The problem asks you to reorder an array so all even numbers come before odd numbers, preserving relative order if needed (or not, depending on the variant). With a 76% acceptance rate, it looks deceptively simple, but the trick is doing it in one pass without extra space. Most candidates brute-force a sort or use extra arrays and leave points on the table. If this hits your live assessment and you blank on the optimal two-pointer move, StealthCoder solves it in seconds while staying invisible to the proctor.

Companies asking
1
Difficulty
EASY
Acceptance
76%

Companies that ask "Sort Array By Parity"

If this hits your live OA

Sort Array By Parity is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.

Get StealthCoder
What this means

The naive approach is to filter evens, filter odds, concatenate. That works but wastes memory and looks sloppy. The real pattern: two pointers, one at each end. Swap an odd found on the left with an even found on the right, moving inward until they meet. It's a textbook two-pointer technique, same skeleton as partition in quicksort. The catch most people miss is handling the swap logic correctly when pointers cross or when one pointer finds all valid elements before the other stops. This problem teaches the pattern you'll see again in harder variants. The two-pointer trick is where candidates either nail it or get stuck re-iterating. StealthCoder is the hedge if the pattern doesn't click during the live OA and time pressure kicks in.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Sort Array By Parity recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sort Array By Parity interview FAQ

Is this problem actually easy or just rated that way?+

It is genuinely easy if you know the two-pointer pattern. The 76% acceptance rate confirms most candidates solve it. The trick is clean in-place swapping. If you're seeing it in an OA, it's usually an opener to build confidence or a filter to catch people who can't write pointer logic without bugs.

Do I have to preserve the original order of evens and odds?+

Depends on the variant. Most online judges don't require stable sort, so you can swap freely. Check the problem statement carefully. If stability is required, two pointers still works but you need a slightly different approach. The easy version skips this constraint.

How does this relate to Sorting and Array topics?+

It combines array manipulation with a sorting-adjacent pattern. You're not sorting in the traditional sense, but you're partitioning. This is the stepping stone to quicksort's partition logic and harder two-pointer problems like container-with-most-water.

What's the biggest mistake candidates make here?+

Off-by-one errors in the pointer logic, not handling the base case where an array is already sorted, or using extra space when the problem wants O(1) space. Some people also forget to advance pointers correctly after a swap, causing infinite loops.

Will I see this at DXC Technology or other companies?+

DXC Technology has reportedly asked it. It's a low-friction opener used to assess basic array and pointer fluency. Expect it more often in earlier rounds or as a warm-up before harder problems in a full loop.

Want the actual problem statement? View "Sort Array By Parity" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.