TikTok Interview Question

coding assessment - leet code hard