Compute delay times in priority array | Amazon Interview Question