Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- 프로그래머스
- PYTHON
- 편스토랑
- programmers
- leetcode
- SW Expert Academy
- 캐치카페
- ChatGPT
- gs25
- 코로나19
- AI 경진대회
- hackerrank
- 맥북
- dacon
- 더현대서울 맛집
- Baekjoon
- 프로그래머스 파이썬
- 우분투
- 자연어처리
- 파이썬
- ubuntu
- Real or Not? NLP with Disaster Tweets
- Docker
- 금융문자분석경진대회
- 백준
- Git
- 편스토랑 우승상품
- 데이콘
- Kaggle
- github
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 69. Sqrt(x) (Python) 본문
728x90
반응형

Implement int sqrt(int x).
Compute and return the square root of x, where x is guaranteed to be a non-negative integer.
Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.
Example 1:
Input: 4
Output: 2
Example 2:
Input: 8
Output: 2
Explanation: The square root of 8 is 2.82842..., and since
the decimal part is truncated, 2 is returned.
Solution
import math
class Solution:
def mySqrt(self, x: int) -> int:
answer = int(math.sqrt(x))
return answer



SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
| [SW_Expert_Academy] 5162번 두가지 빵의 딜레마 (Python) (0) | 2020.05.21 |
|---|---|
| [leetCode] 66. Plus One (Python) (0) | 2020.05.20 |
| [leetCode] 8. String to Integer (atoi) (Python) (0) | 2020.05.18 |
| [BaeKJoon] 11727번: 2xn타일링 2 (Python) (0) | 2020.05.17 |
| [BaekJoon] 2579번 : 계단 오르기 (Python) (2) | 2020.05.16 |
Comments