The solution you wrote doesn’t match the solution posted.
The most recent solution was posted on June 13 and both solutions have used {}s since that day.
The previous version used different whitespace than you posted here. If you use the code as it was originally posted and add {} as the original whitespace indicates, the older version of the solution works fine. The nested loop bodies are single statements.