Need help in this problem

Where i am going wrong with my approach. Am i missing something?
Problem link here
My code here