TikTok interview question

Circular Printer superstack ancestor problem