Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
sqrt is calculated 2 times :(
I think this is the best one, I tried some mathimatical operations but this one didn't cross my mind
Nice, it takes off the decimal and checks it aginst the actual case. Cool solution!
He's checking to see if the sqrt() function has decimals by comparing the base sqrt(n) to the rounded down version (floor()) of sqrt(n). If they are equal and the function returns true, then sqrt(n) must have no decimals. Thus, n is a perfect square.
why are you using floor specifically?
floor in C++
What does the function floor do?
Have you included math with
#include <math.h>
? You don't even needpow
tho.This comment is hidden because it contains spoiler information about the solution
It looks like you're using
double
s. They have 53-bit significand, so they can't have odd values greater than 2^53.https://en.wikipedia.org/wiki/Double-precision_floating-point_format
i've been stuck at this problem for a day now. My solution is O(sqrt(n)) and it's still failing. A little hint wouldn't hurt anyone. Please help.
This comment is hidden because it contains spoiler information about the solution
The description refers to a thing which is either known under a different name or is not available altogether in some of the available languages. This message should be removed from the description.
Can you explain how maps would be more efficient at these sort of problems?