Amazon Interview Question

Q1 closest sum Q2 heap question