Whatnot Interview Question

Coding question on internal problem