leetle

Daily challenge for 2026-07-19

565. Peak Robot Manhattan Distance

Given an array of movement commands commands where each command is a string "U" (up), "D" (down), "L" (left), or "R" (right), the robot starts at coordinates (0, 0). Find the maximum Manhattan distance from the starting position reached at any point during the sequence of movements. The Manhattan distance of a coordinate (x, y) from the origin is defined as |x| + |y|.

Example:
Input: commands = ["R", "U", "R", "D"]
Output: 3
Explanation: The robot moves as follows: (0,0) -> (1,0) [dist 1] -> (1,1) [dist 2] -> (2,1) [dist 3] -> (2,0) [dist 2]. The peak distance reached is 3.

Run this challenge interactively in Python or JavaScript when the app loads.