Merge overlapping intervals | Microsoft Interview Question