[leetcode-python3] 69. Sqrt(x)

shsh·2020년 12월 19일
0

leetcode

목록 보기
33/161

69. Sqrt(x) - python3

Given a non-negative integer x, compute and return the square root of x.

Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.

My Answer 1: Accepted (Runtime: 24 ms - 97.84% / Memory Usage: 14.2 MB - 22.90%)

class Solution:
    def mySqrt(self, x: int) -> int:
        return int(sqrt(x))

이건 거의 10초컷이었는데.. 풀고도 의아했던 난이도..
sqrt 함수 안쓰고 내가 직접 만드는건지 뭔지...;

int() 형변환 대신 trunc 함수를 사용해도 된다

profile
Hello, World!

0개의 댓글

관련 채용 정보