Ezvor

3540. Minimum Time to Visit All Houses

MediumArray Preparing judge… LeetCode
ArrayPrefix Sum

Hints

Hint 1
Use prefix sums to compute distances for both forward and backward movements.
Hint 2
For each move between adjacent houses, take the minimum distance from the two prefix-sum arrays.