Meta Interview Question

basic algo question and 2nd one is more difficult