adding floating point numbers in sqrt make them more accuracte
i submitted a solution containing
int sq = sqrt(sum);
if (sq * sq == sum && sq % 2 == 1) cnt++;
although this seems perfectly fine, it doesn't pass the test case listed below
`14'
'1 10 10 100 1 1 10 1 10 2 10 2 10 1`
this must return 3 as the first,fourth and last number fit the condition but returns 2
the issue with it is that sqrt works well with floating point numbers this code fixes the rounding issues
long long sq = (long long)sqrt(sum + 0.5); // Add 0.5 to handle rounding issues
if (sq * sq == sum && sq % 2 == 1) cnt++;
Auto comment: topic has been updated by atulcf24 (previous revision, new revision, compare).
use sqrtl for numbers that exceeds the int limit for higher precision
169 was the case where it failed
My code was working with typecasting and without the need for approximation
oh nice, mine wasn't