Reported October 2022
Bloombergsimulation

Maximize Circular Rover Travel

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

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

The Bloomberg OA reported in October 2022 hands you a rover on a circular route, a list of [position, fuel] stops, and one rule that trips people up: one unit of distance burns one unit of fuel. You pick any starting stop and drive clockwise, grabbing fuel as you reach each stop. With stops.length capped at 2000, an O(n^2) simulation is the intended path. If the circular bookkeeping scrambles your head mid-assessment, StealthCoder is the quiet backup that reads the screen and gives you a working solution.

The problem

A circular route has length circumference. Each stops[i] = [position,fuel] has a distinct position. Choose any stop as the start and collect its fuel. Traveling one distance unit consumes one fuel.
Moving clockwise, collect each reached stop at most once. If fuel cannot reach the next uncollected stop, travel until fuel is exhausted. After collecting every stop, continue until remaining fuel is exhausted without collecting stops again. Return the maximum total distance traveled.

Function
maximumRoverDistance(circumference: int, stops: int[][]) → long

Examples
Example 1
circumference = 100
stops = [[0,10],[10,30],[60,40]]
return = 80
Start at 60, wrap to 0, then reach 10 and use the remaining fuel to stop at position 40 after 80 total distance.

Constraints
1 <= stops.length <= 2000.
0 <= position < circumference.
Fuel amounts are nonnegative.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that the start choice is the only decision. Everything after it is forced, so you try every stop as the start and simulate. Sort stops by position first. From a start, keep a fuel tank and a distance counter. Loop clockwise: compute the gap to the next stop, which wraps with modulo against circumference. If fuel covers the gap, subtract it, add the distance, then add that stop's fuel. If not, add the remaining fuel to distance and stop. Once all stops are collected, add whatever fuel is left, since the rover keeps driving until empty. Take the max over all starts. The common pitfall is the wrap gap for the start stop itself and using int for totals when the answer is long. Zero-fuel stops and a fuel total of exactly the gap are edge cases. StealthCoder is your hedge if the wraparound indexing falls apart live.

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 Maximize Circular Rover Travel 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 Bloomberg's OA.

Bloomberg 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.

Maximize Circular Rover Travel FAQ

What's the trick in Maximize Circular Rover Travel?+

Try every stop as the starting point and simulate the forced clockwise drive. Once you pick the start, nothing else is a choice. With at most 2000 stops, n starts times n steps is fine, so don't hunt for something fancier.

How hard is this Bloomberg OA question really?+

Medium. The idea is simple, but the circular gaps and the end condition cause bugs. Most failures come from the wraparound distance and from forgetting that leftover fuel still adds distance after every stop is collected.

How do I handle the circular wraparound?+

Sort stops by position. The gap from stop i to the next is (pos[next] - pos[i] + circumference) % circumference. Walk indices with modulo n. Be careful with a single stop, where the full loop is the gap.

Do I need long for the answer?+

Yes. The function returns long, and fuel amounts can be large across up to 2000 stops. Accumulate fuel and distance in 64-bit types so the total doesn't overflow in your language.

How do I prepare for this in 48 hours?+

Write the simulation once on the sample: start at 60, wrap to 0, reach 10, and finish at 80 total. Then test a single stop, zero-fuel stops, and fuel that exactly equals a gap. Those cases cover most of the hidden failures.

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

OA at Bloomberg?
Invisible during screen share
Get it