Google Interview Question

2 algorithm question on screen--easy to medium