Solve interval deletion and GCD subarray problems | Amazon Interview Question