Maximum Length of Subarray With Positive Product
A medium-tier problem at 44% community acceptance, tagged with Array, Dynamic Programming, Greedy. Reported in interviews at Arcesium and 0 others.
Maximum Length of Subarray With Positive Product is a medium-difficulty problem that appears in assessments for companies like Arcesium. You're given an array of integers and need to find the longest contiguous subarray with a positive product. The catch: you can't just multiply values and check the sign. The problem forces you to think about how negative numbers propagate through a product, and most first attempts either miss edge cases around zeros or waste time on brute force. This is exactly the kind of problem where the pattern isn't obvious on first read, and blanking during a live OA is common. If you hit this one, StealthCoder solves it invisibly while you think.
Companies that ask "Maximum Length of Subarray With Positive Product"
Maximum Length of Subarray With Positive Product 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. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe trick here is recognizing that you track two states at each index: the longest subarray ending here with a positive product, and the longest with a negative product. When you hit a negative number, those states flip (negative becomes positive, positive becomes negative). Zeros reset both counters because any product containing zero is zero, which kills your positive streak. The greedy insight is that you always want to extend your current subarray rather than restart, because a single negative can flip a negative product back to positive. Most candidates try to simulate the product value itself, which overflows or misses the state-tracking insight. The dynamic programming framing makes it click: dp_pos and dp_neg track lengths, not values. If this pattern doesn't surface during your prep, StealthCoder runs invisibly during the assessment and delivers the two-state solution in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Maximum Length of Subarray With Positive Product 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. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Length of Subarray With Positive Product interview FAQ
Is this problem actually about DP or just greedy state tracking?+
It's both. You maintain two DP states (longest positive, longest negative subarray at each index), but the recurrence is greedy: you always try to extend rather than reset. The problem is categorized as DP in most lists, and that framing helps you recognize the state-tracking pattern during the live OA.
What's the difference between this and maximum subarray product?+
Maximum subarray product tracks the actual product values to find the maximum. This problem only cares about the product's sign (positive vs. negative) and finds the longest subarray. You never compute actual products, just lengths and state transitions at each index.
Why do zeros matter so much in this problem?+
A zero makes any product zero, which is neither positive nor negative. It breaks both your positive and negative streaks. Handling zeros correctly is the most common bug: many candidates forget to reset both counters when they encounter zero.
Is this problem still asked at Arcesium and similar companies?+
Arcesium is documented as asking this problem. It appears in medium-difficulty rounds and tests your ability to think in terms of state transitions rather than direct computation. The acceptance rate sits around 44 percent, reflecting its non-obvious pattern.
What's the most common pitfall during the live assessment?+
Trying to track the actual product value instead of just the sign and length. Candidates either overflow on large inputs or miss that flipping signs via negatives is the core insight. The state-tracking approach eliminates both problems.
Want the actual problem statement? View "Maximum Length of Subarray With Positive Product" on LeetCode →