Need Urgent solution for this in JAVA

// - A series of cars are traveling along a one-lane road at different speeds.
// The cars may not pass each other so that faster cars are forced to wait on
// the slower cars, resulting in several cars being clustered together.
// - Part 1: Compute the number of clusters and the length of each cluster
// of cars.

// Parameters
// ------------
// car_speeds - a list of postive integers detailing the speeds at
// which the cars are traveling. The first item in the list
// corresponds to the car in the front.

// Examples
// ---------
// calc_car_clusters([2, 4, 1, 3]) -> [2, 2]
// calc_car_clusters([2, 5, 4, 3, 1]) -> [4, 1]

// # // Part 2: Consider the case where a new car, faster than the existing
// # // cars, is added to the mix. How will the clusters be affected if the
// # // new car is inserted in each of the possible positions in the list?
// # // You may call your previous function a maximum of one time.

// # //Examples
// # // ----------
// # // calc_car_cluster_insertion([2, 4, 1, 3]) -> [
// # // [1, 2, 2], [3, 2], [3, 2], [2, 3], [2, 3]
// # //]

Comments (1)