As reported: D. E. Shaw SMTS online assessment (2025), question 1 of 2, related to LeetCode 2742 — Painting the Walls.
This is LeetCode 2742 — Painting the Walls. Our write-up: /painting-the-walls.
There are n walls. cost[i] and time[i] are the money and time the paid painter needs for wall i. A free painter paints any wall in 1 unit of time at no cost, but can only work while the paid painter is busy.
Return the minimum cost to paint all n walls.
Example 1
cost = [1,2,3,2], time = [1,2,3,2]
Output: 3
The paid painter takes walls 0 and 1 (3 time units, cost 3); meanwhile the free painter paints walls 2 and 3.
Example 2
cost = [2,3,4,2], time = [1,1,1,1]
Output: 4
Constraints: 1 ≤ cost.length ≤ 500; cost.length == time.length; 1 ≤ cost[i] ≤ 10^6; 1 ≤ time[i] ≤ 500.
Code runner format: one JSON value per line: cost, then time. Implement paintWalls(cost, time).