일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Pseudo Lab
- Python
- 데이터 엔지니어
- Data Engineering
- 2023년 목표
- delete join
- leetcode
- airflow architecture
- telegram
- Spark
- 알고리즘
- 백준 온라인 저지
- dsf
- 그리디
- SQL
- datacamp
- Dynamic Programming
- terraform
- Airflow
- 프로그래머스
- BOT
- docker container
- hackerrank
- MySQL
- docker
- data_engineer
- airflow webserver
- 백준온라인저지
- 빅데이터를 지탱하는 기술
- docker image
Archives
- Today
- Total
Lim Seunghyun Space
[Leetcode] Valid Perfect Sqaure 본문
문제 출처
Valid Perfect Square - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제 해설
- 1보다 크고 2^31 - 1보다 작은 정수(num)가 어떤 수의 제곱수인지 확인하는 문제
문제 풀이
# source: https://leetcode.com/problems/valid-perfect-square/?envType=study-plan&id=binary-search-i
class Solution:
def isPerfectSquare(self, num: int) -> bool:
i = 1
while i**2 <= num:
if i**2 == num:
return True
i += 1
return False
- 1부터 하나씩 증가시켜 그 값의 제곱한 결과가 num과 같은지 확인
- 제곱한 결과가 num보다 큰 경우에는 반복을 종료
Github
728x90
'Algorithm > 문제' 카테고리의 다른 글
[LeetCode] 513. Find Bottom Left Tree Value (0) | 2023.04.06 |
---|---|
[Leetcode] First Bad Version (0) | 2022.12.05 |
[Leetcode] Peak Index in a Mountain Array (0) | 2022.11.26 |
[Leetcode] Search Insert Position (0) | 2022.11.24 |
[Leetcode] Guess Number Higher or Lower (0) | 2022.11.24 |