Merge overlapping intervals | Amazon Interview Question