Ever think about the sqrt of 1 are 1 and -1?


  • 0
    R

    Ever think about the sqrt of 1 are 1 and -1?


  • 0
    M

    The mathematical square root of 1 is both 1 and -1, but that's not the only instruction. There's also Implement int sqrt(int x). None of the sqrt functions I can think of have returned the negative value as well as the positive, trusting that if you need it, you know that the negative root is -1*positive root, so can obtain it easily, without the hassle of returning multiple numbers or finding which one you want in the list.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.