TikTok Interview Question

Given example data, use SQL to get output in this format.