TikTok Interview Question

a variation of Josephus problem was asked