Minimize time for two handlers | Amazon Interview Question