Feature #2: Path Cost
Implementing the "Path Cost" feature for our "Uber" project.
We'll cover the following
Description
Now that some drivers have been selected, we need to calculate the cost required to travel between different checkpoints. The cost depends on the amount of water accumulated in different parts of the road. We know that water collects on roads that are either broken or uneven. We will use an API to access the data regarding water on the road, it will transform the 3D layout of the road into a nice 2D layout of water trapped between different parts of the road.
We’ll be given an array whose length is equal to the length of the road between two checkpoints. Each integer value in the array will represent the combined elevation(in cm) of the road at the points where it is broken. We need to find how much total water(in cm) will be accumulated in the spaces left between different elevations of the broken road.
Below is an illustration of this process:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.