OA
Problem 1
There are n cities, each with a deliveryCharge value. Delivering from city i to city j can be costed in two ways:
- The cost is abs(deliveryCharge[i] - deliveryCharge[j])
- If city j is city i's unique nearest city, the cost is 1
The distance between cities is defined as abs(deliveryCharge[i] - deliveryCharge[j]). Given a queries array where each entry is [Start, End], compute the minimum delivery cost from Start to End.
Problem 2
On a one-dimensional lane of length laneLength (ranging from 0 to laneLength), there are multiple trucks at different initial coordinates, each with its own velocity:
- A positive velocity means the truck moves right, a negative velocity means it moves left
- A truck is considered to have left the lane once it goes past the lane's boundary
- When two trucks collide, they swap velocity and direction
The task is to output the time at which the last truck leaves the lane.
Problem 3
The company's employees are organized as a tree, with the Root being the Boss. When data is passed to an employee, it is passed on to all of that employee's direct reports in ascending order of their child node values.
The input is a boss array, where boss[i] is the manager of employee i. Given a queries array, each query contains [StartNode, k]:
- Following the ascending-order propagation rule described above, find the k-th employee to receive the data starting from StartNode
- Return that employee's ID
Discussion
Loading comments…