TikTok Interview Question

paint the graph using any algo