Minimum Toll — Strait of Hormuz
AeroSpace • Anduril • Hard • grid DP + no consecutive turns
The Strait of Hormuz is a critical maritime choke point. You are given a 2D grid of size m×n.
Each cell is an escort cost (thousands of USD), or −1 for a military exclusion / land mass ships cannot enter.
Start at the top-left (0,0) and reach the bottom-right (m−1,n−1).
Ships may move only Down or Right. Due to congestion they cannot make two consecutive turns:
if the ship moves Down then Right (a turn), its next move must be Right again.
Return the minimum total cost, or −1 if impossible.
Example 1: [[0,4,2],[1,-1,1],[1,3,0]] → 5
via Down,Down,Right,Right (0+1+1+3+0). Turning Right→Down and then immediately Down→Right on the next step is illegal.
Example 2: [[0,-1],[-1,0]] → −1 (both exits from the start are exclusion zones).
Constraints: 1≤m,n≤100; cells are −1 or in [0,10⁴]; start and goal are never −1.
Demo walkthrough uses Example 1.