Minimum Paired Height-Lowering Operations
Updated
Problem statement
You are given initial tile heights initial and desired heights target.
One operation chooses an interval [L,R], two distinct positions inside that interval, and a nonnegative integer height h. The chosen height must be at most every current height in the entire interval. Set the heights at exactly those two chosen positions to h; the other positions do not change.
Return the minimum number of operations needed to reach the target array, or -1 if it is impossible. A selected tile is allowed to stay at its current height. In a one-tile array no operation is possible.
Function
minimumHeightOperations(initial: int[], target: int[]) → intExamples
Example 1
initial = [3,3,3]target = [2,1,1]return = 2First choose interval [0,1] and set positions 0 and 1 to 2, obtaining [2,2,3]. Then choose interval [1,2] and set both positions to 1, obtaining [2,1,1]. Three tiles must decrease and one operation changes at most two, so at least two operations are needed.
Example 2
initial = [3]target = [2]return = -1The only position must decrease, but an operation requires two distinct positions. No operation is available.
Constraints
- 1 <= initial.length <= 2000
- target.length == initial.length
- 0 <= initial[i], target[i] <= 1000000000
Source note: Screenshot of the public LeetCode discussion text describing the reported Adobe OA task. The practice version adds the details stated in the source note.
More Adobe Online Assessment questions
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
- Minimum Numeric Code TransformationOA · Seen Aug 2026
Similar questions at other companies
- Minimum Cost to Supply Water with Wells and PipesInfosys · OAInfosys interview questions
- Optimize Log FileGoogle · OAGoogle interview questions
- Doctor Appointment Slot AssignmentDRW · OADRW interview questions
- Unit Jobs with Deadlines and ProfitsJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximum Edge Removals for Two TravelersMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
- Water Supply With Wells and PipesNutanix · ONSITE INTERVIEWNutanix interview questions
- Minimum Cost for Roads and HospitalsAmazon · ONSITE INTERVIEW
- Split Array Largest SumAuxoAI · OA
- Delete and Freeze GameRubrik · OARubrik interview questions
- Lock CodeVisa · OAVisa interview questions
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
- Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)