The problem seems straight forward. If the number is a perfect square then yes, otherwise no. But I am getting WA. Then I came across this blog.

I am having trouble with this line

if(s*s==n || (s-1)*(s-1)==n || (s+1)*(s+1)==n)

In my code, I only used s*s==n. Why are the rest required? I mean s is simply the typecasted value, and has to be less than or equal to the sqrt(n). Correct me if I am wrong.