Question: American express coding round oa questions | 24sep 2025 | Crane Routing Problem | Amex oa questions | Cracking the Amex Coding Round | Interval Overlap & Reachability Logic
0
Entering edit mode

Question 1: The Crane Routing Problem

Problem Statement:

There are N cranes (numbered from 0 to N-1) arranged in a line along a road. Road begins at position 0. The K-th crane is located at distance P[K] from the beginning of the road and its arm length is equal to A[K]. The cranes cannot change their positions.

There is a package, initially located at position B, that has to be moved by the cranes to position E. The K-th crane can pick up the package only if the distance between its position and the package position is less than or equal to A[K] (the package is within arm range from the crane's position). A package can be moved by a crane to an arbitrary position within the crane's arm reach (between P[K] - A[K] and P[K] + A[K] for the K-th crane).

Example:

For example, if P[K] = 5 and A[K] = 3, the K-th crane can move packages anywhere between positions 2 and 8, including both of the boundaries.

Objective:

Determine whether it is possible to move the package from position B to position E using some (possibly all) of the cranes. Any crane can be used an arbitrary number of times.

Write a function to solve this logic.

 

Login before adding your answer.

Similar Posts
Loading Similar Posts