What is wrong with this code?

You need to modify your approach a little bit. Try to look at this video to have a better understanding of the problem as :