Amazon Interview Question

two easy leetocode questions, one is two pointer, the other one is binary search