A warehouse robot moves across a rectangular floor divided into tiles. Each tile has a surface resistance value.
The strain caused by moving between two neighboring tiles is the absolute difference between their resistance values. The suspension strength needed for a route is the largest strain produced by any move on that route.
Find the minimum suspension strength that allows the robot to travel from the top-left tile to the bottom-right tile.
WarehouseRobotRoutePlanner
int minimumSuspensionStrength( List<String> surfaceResistance )
surfaceResistance: A list of strings representing the warehouse floor. Each string contains one row of comma-separated resistance values.Return the minimum suspension strength required to reach the bottom-right tile from the top-left tile.
surfaceResistance represents one row."5,8,12" represents a row containing the resistance values 5, 8, and 12.(0, 0).0.1 ≤ surfaceResistance.size() ≤ 1001 and 100 comma-separated integers.1 ≤ resistance value ≤ 1,000,000 minimumSuspensionStrength( surfaceResistance = ["6,2,3", "7,12,4", "8,9,5"] )
Output: 4
The robot can follow the values 6 → 2 → 3 → 4 → 5. The move strains are 4, 1, 1, 1, so this route requires strength 4. No route can use a smaller maximum strain.
minimumSuspensionStrength( surfaceResistance = ["20,21,30", "18,40,29", "17,16,15"] )
Output: 2
The robot can follow the values 20 → 18 → 17 → 16 → 15. The largest strain on this route is 2.
minimumSuspensionStrength( surfaceResistance = ["5", "11", "8", "12"] )
Output: 6
Only one route exists. Its move strains are 6, 3, 4, so the required suspension strength is 6.
minimumSuspensionStrength( surfaceResistance = ["250"] )
Output: 0
The starting tile is also the destination, so the robot does not make any move.