TikTok interview question

LC-style question: Construct product matrix