G-Research interview question

time complexity for certain events