Microsoft interview question

Time and space complexity, average and worst case