G-Research Interview Question

time complexity for certain events