Sponsored
Use these hints if you're stuck. Try solving on your own first.
We want to always choose the most common or second most common element to write next. What data structure allows us to query this effectively?
Solve with full IDE support and test cases