Problem · Dynamic Programming
Optimal Path in a Grid
Learn this problemProblem statement
You are given two arrays, A and B, each made of N integers. They represent a grid with N columns and 2 rows, where A is the upper row and B is the lower row.
Your task is to go from the upper-left cell (represented by A[0]) to the bottom-right cell (represented by B[N-1]) moving only right and down, so that the maximum value over which you pass is as small as possible.
Given two arrays of integers, A and B, of length N, returns the maximum value on the optimal path.
Function
solution(A: int[], B: int[]) → intExamples
Example 1
A = [3, 4, 6]B = [6, 5, 4]return = 5
The optimal path is 3 → 4 → 5 → 4.
Example 2
A = [1, 2, 1, 1, 1, 4]B = [1, 1, 1, 3, 1, 1]return = 2
Constraints
...More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026