Google Interview Question

time complexity and space complexity