Confluent interview question

Leetcode hard question