MEDIUMasked at 1 company

Rearrange Array Elements by Sign

A medium-tier problem at 84% community acceptance, tagged with Array, Two Pointers, Simulation. Reported in interviews at Infosys and 0 others.

Founder's read

Rearrange Array Elements by Sign hits your screen and you have to arrange positive and negative numbers in a specific order without losing the original sequence. It's not hard, but the trick isn't obvious if you don't see the pattern immediately. Infosys asks this one, and at 84% acceptance, most people who prep solve it. The catch is that the straightforward approach wastes space or time, and you need to know which one to kill first. If you blank on the optimal path during your live assessment, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
84%

Companies that ask "Rearrange Array Elements by Sign"

If this hits your live OA

Rearrange Array Elements by Sign 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 by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.

Get StealthCoder
What this means

The pattern is simple once you see it: alternate between positive and negative numbers while respecting their original order. The naive approach is to build two separate lists (one positive, one negative), then zip them together. That works and passes, but it's not the tightest move. The real trick is two pointers on a single output array, filling even indices with one sign and odd indices with the other, then walking through your input to place each number in the correct slot. The failure mode is forgetting that order matters within each sign group, or trying to do it in-place on the input and corrupting your data. Array and Two Pointers are the core topics here; Simulation comes in when you're actually executing the placement logic. Most candidates either solve it cleanly the first way they think of it, or they get stuck overthinking space complexity. StealthCoder is your hedge if you hit a logic wall during the live OA and need a working implementation fast.

Pattern tags

The honest play

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

Rearrange Array Elements by Sign recycles across companies for a reason. It's medium-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 by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Rearrange Array Elements by Sign interview FAQ

Is this problem actually easy or medium?+

It's medium in name but easy in execution if you've seen the pattern. At 84% acceptance, most people who attempt it pass. The friction isn't algorithmic; it's knowing whether to use two separate lists or two pointers on one output array. Either approach is fine.

Does Infosys still ask this in their assessments?+

Yes. It's reported as recently asked by Infosys and fits their range of array manipulation problems. It's not a frequent ask across all companies, but if you're interviewing there, prepping this one is smart.

What's the trick I'm missing if I can't solve it quickly?+

You're probably overthinking space or trying to rearrange in-place. The two-pointer approach fills an output array at even and odd indices, respecting input order. Build two lists first if that's clearer; optimize later if you have time.

How does Two Pointers connect to this problem?+

Two Pointers tracks your position in the output array (alternating even and odd indices) while a single pointer walks the input. This avoids building intermediate lists and is more elegant, though not mandatory for acceptance.

Will I see this again if I solve it once?+

Maybe. Array rearrangement patterns repeat, but this specific variant is lower frequency across the interview circuit. Solving it preps you for the broader category of sign or sign-related ordering problems.

Want the actual problem statement? View "Rearrange Array Elements by Sign" 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.