As 0 is a perfect square, shouldn’t the answer for N = 1 be 0? But it is given as -1 in the sample test case. What is wrong with my code? I have manually tested a bunch of test cases myself and I am getting the correct answer. If N is a perfect square should the answer be 0 or something else?

this is the ideon link for my code - I have written code for both possibilities ie. considering 0 as a perfect square and 0 as not a perfect square(as given in sample test case) and I am getting WA for both submissions. Please help.

1 Like

Paste your code here so that I can help you

1 Like

0 is not considered as a perfect square.

If a number is already a perfect square then also you have to add another perfect square so that it becomes perfect square.

1 Like

Sorry…here is the link