Intel Corporation Interview Question

generic leetcode question about colored balls