Solve array duplicates and two-type subarray | Amazon Interview Question