Amazon Interview Question

Two difficult array related questions.