I have come across this question in a review. In a departure from usual homework questions, this one is a homework assignment along with proposed solutions, and asks whether they are correct.
Is this a valid question for Stack Overflow?
From the "What's On Topic?" Help Center page:
Questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it.
There is a summary of the work done to solve the problem - the proposed answers. But the asked isn't having any specific difficulty in solving it, so there's nothing to describe.
On the other hand, the question seems to be the programming equivalent of "Proof read this for me", which I know is first on the list of English Language & Usage Stack Exchange's off-topic questions - is there a similar policy here that I haven't noticed before now?