Trains the technique from
LeetCode 2833Furthest Point From OriginThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A window-washing cradle begins the day parked at its rest position on the side of a tower. The shift log moves records, in order, what the cradle did during each stage of the day. One character stands for one stage:
'U' means the cradle rose exactly one floor,'D' means the cradle dropped exactly one floor,'?' means the entry is smudged, and that stage was either a rise of one floor or a drop of one floor.The offset at the end of the day is how many floors separate the cradle's final position from its rest position, counted without regard to direction. Each smudged stage may be read either way, and two smudged stages need not be read the same way.
Return the largest offset that is consistent with the log.
Example 1
Reading both smudged stages as drops leaves the cradle two floors below the rest position, so the offset is 2.
Example 2
Reading the smudged stage as a drop leaves the cradle three floors below the rest position, so the offset is 3.
Example 3
Reading all six smudged stages as rises leaves the cradle six floors above the rest position, so the offset is 6.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def furthest_offset(moves: str) -> int:public int furthestOffset(String moves)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.