TikTok interview question

1. Time and space complexity