Solution with explanatory comments