Compute window averages and merge intervals | WeRide Interview Question