Bloomberg Interview Question

Time and space complexity of the above functions.