Maximum Product of a Strictly Increasing Contiguous Subarray
Reported by candidates from Infosys's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure here is just the array itself, plus a couple of running variables. Infosys reported this OA in August 2026, and it looks like a monster until you notice that strictly increasing runs can't overlap. Split the array wherever nums[i] is not less than nums[i+1], and every run is its own small problem. Negatives are the trap. Example 3 returns 20, not -60, because the best answer is a sub-slice of the run. If you blank on the live OA, StealthCoder is the invisible safety net sitting on your desktop.
The problem
Given an integer array nums, choose a non-empty contiguous subarray whose values are in strictly increasing order. A subarray nums[l..r] is eligible when nums[i] < nums[i + 1] for every index i from l through r - 1. A subarray containing one element is eligible. Return the maximum product of the elements in any eligible subarray. Function maximumProductIncreasingSubarray(nums: int[]) → long Examples Example 1 nums = [2,3,4] return = 24 The entire array is strictly increasing, and its product is 2 * 3 * 4 = 24. Example 2 nums = [3,2,4,5] return = 40 The increase breaks between 3 and 2. Within the increasing run [2,4,5], the subarray [2,4,5] has product 40, which is the maximum. Example 3 nums = [-5,-4,-3] return = 20 The array is strictly increasing, but using every element gives -60. The eligible subarray [-5,-4] has product 20, which is larger than every other eligible product. Constraints 1 <= nums.length <= 100000 -1000000000 <= nums[i] <= 1000000000 The product of every eligible subarray fits in a signed 64-bit integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Break the array into maximal strictly increasing runs. Inside a run, values only go up, so the negatives come first, then maybe a zero, then the positives. That structure is the whole trick. The best subarray inside a run is either a prefix of negatives with an even count, or a window that includes the positives. Brute force each run with an O(k^2) product loop and you'll time out at 100000 elements. Better: for each run, the sign pattern is sorted, so check a few candidates. The negative block's best even-length pair-up, the positive tail, and a combination of both, with zeros acting as hard resets. A cleaner route is tracking running max and min product ending at each index, restarting when the run breaks. The pitfall is forgetting that a single element counts, and that the answer is a long. If you freeze mid-assessment, StealthCoder can hand you the clean version.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Maximum Product of a Strictly Increasing Contiguous Subarray cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Infosys's OA.
Infosys reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Product of a Strictly Increasing Contiguous Subarray FAQ
What's the trick in the Infosys maximum product increasing subarray problem?+
Split the array into maximal strictly increasing runs, then solve each run on its own. Track the max and min product ending at each index, because a negative times a negative flips the sign. Reset both whenever nums[i] is not greater than the previous value.
Why does Example 3 return 20 and not -60?+
The whole array is eligible but its product is negative. Any contiguous slice is also eligible, so [-5,-4] gives 20. You must consider sub-slices of a run, not just the full run. That's why simply multiplying a whole run fails.
How hard is this one really?+
Medium. The run-splitting is easy to see. The sign handling is where people lose points. With up to 100000 elements you need roughly linear time, so any nested product loop over a long run is out.
What edge cases should I test before submitting?+
Test a single element, all negatives, a zero inside a run, equal adjacent values that break a run, and a strictly decreasing array where every answer is one element. Also use a 64-bit type for the product, since the statement guarantees it fits.
How do I prepare for this in 48 hours?+
Do the maximum product subarray problem until the max/min tracking feels automatic. Then add the reset rule for broken runs. Write it once from memory, run your own tests on the three examples, and you're ready for the Infosys version.