Here is a link to the original problem on Interview Cake. In short, you have the following code. The syntax is correct, but the behavior is off.
It didn’t take me long to figure out the actual issue, but the solution was a different story. It eluded me for several minutes. Here’s my solution minimized.