Compute centered averages and merge intervals | WeRide Interview Question