Reported July 2025
Nuroprefix sum

Maximum Value for Two Delivery Robots

Reported by candidates from Nuro's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Nuro OA. Under 2s to a working solution.
Founder's read

The trap in Nuro's two-robot delivery problem is assuming the first robot's segment has to come first on the street. It doesn't, and a solution that only checks one ordering fails on the July 2025 reports. This is a prefix-sum problem with a sliding window sum on top. You've got two fixed-length segments, they can't overlap, and either can be on the left. Arrays go up to 200000 elements, so brute force over pairs of positions is dead on arrival. If you blank mid-assessment, StealthCoder runs invisibly as a safety net. But the pattern is short enough to lock in tonight.

The problem

Houses lie in a row, and values[i] is the delivery value at house i. Two robots must serve non-overlapping contiguous segments of houses.
For this exercise, assume the first robot serves exactly c1 consecutive houses and the second robot serves exactly c2 consecutive houses. Either robot's segment may appear first along the street.
Return the maximum total value served by the two robots.

Function
maxDeliveryValue(values: int[], c1: int, c2: int) → long

Examples
Example 1
values = [4,2,3,5]
c1 = 2
c2 = 1
return = 12
The second robot serves the first house for value 4. The first robot serves the final two houses for value 3 + 5 = 8. The segments do not overlap, and their total value is 12.
Example 2
values = [1,2,3,4,5]
c1 = 2
c2 = 2
return = 14
The robots can serve [2,3] and [4,5]. Their total is 5 + 9 = 14.
Example 3
values = [5,1,1,5]
c1 = 1
c2 = 1
return = 10
Each robot serves one of the two houses with value 5, for a total of 10.

Constraints
2 <= values.length <= 200000
0 <= values[i] <= 10^9
1 <= c1 and 1 <= c2
c1 + c2 <= values.length
The answer fits in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build a prefix sum array so any window sum is O(1). Then compute the best window sum of length c1 ending at or before each index, and the best of length c2 starting at or after each index. Walk the split point: for every position, combine the best left c1 window with the best right c2 window. Then run it again with c1 and c2 swapped, and take the max of both passes. That second pass is the edge case that breaks the naive version. Example 1 shows it, since the c2 robot takes the first house and the c1 robot takes the end. Use 64-bit sums, since values reach 10^9 across 200000 houses. Another pitfall is off-by-one on the window boundaries. Since c1 + c2 <= n, a valid pair always exists. Total time is O(n) with O(n) memory. StealthCoder is the hedge if the index math slips under pressure during the live OA.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Maximum Value for Two Delivery Robots 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 StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Nuro's OA.

Nuro 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 Value for Two Delivery Robots FAQ

What's the trick in the Nuro two delivery robots problem?+

Precompute window sums with a prefix array, then track the best window of one length on the left and the best of the other length on the right of each split. Run both orderings. That gives O(n) instead of checking every pair of positions.

Why do I need to try both orderings of c1 and c2?+

The statement says either robot's segment may come first. If you only place the c1 window left of the c2 window, you miss cases like Example 1, where the single-house robot sits at the start. Run the pass twice with the lengths swapped and take the max.

Do I need long or 64-bit integers here?+

Yes. Values go up to 10^9 and there can be 200000 houses, so sums blow past 32-bit range. The problem says the answer fits in a signed 64-bit integer. Use long in Java or C++. Python handles it on its own.

Can a brute force pass this problem?+

No. Trying every pair of start positions is O(n^2) at n up to 200000, which is far too slow. You need the linear approach with prefix sums and running best-window arrays. Even a clean O(n log n) isn't needed.

How do I prepare for this in 48 hours?+

Practice prefix sums and fixed-size window sums until the indexing is automatic. Then write the two-pass left-best and right-best version from scratch. Test it on the three examples, especially Example 3 with equal values and Example 1 where the order flips.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Nuro.

OA at Nuro?
Invisible during screen share
Get it