728x90
반응형
문제
반응형
풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Solution {
public int mySqrt(int x) {
int answer = 0;
for(long i=1; i<=x; i++) {
if(i * i > x) {
answer = (int) (i-1);
break;
}else if(i * i == x) {
answer = (int) i;
break;
}
}
return answer;
}
}
|
cs |
728x90
반응형
'[JAVA] LeetCode > Easy' 카테고리의 다른 글
[LeetCode/릿코드] 88. Merge Sorted Array (0) | 2023.01.24 |
---|---|
[LeetCode/릿코드] 70. Climbing Stairs (0) | 2023.01.24 |
[LeetCode/릿코드] 67. Add Binary (0) | 2023.01.24 |
[LeetCode/릿코드] 66. Plus One (0) | 2023.01.24 |
[LeetCode/릿코드] 58. Length of Last Word (0) | 2023.01.24 |