Amazon Interview Question

two sum variation and longest increasing subsequence