URS Systems interview question

Time complexity