Twitch Interview Question

Leetcode very difficult with the optimal approach