TikTok Interview Question

1. Time and space complexity