Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Real MySQL
- 알고리즘
- jsp
- 회고
- LeetCode
- 서평
- Python
- 미니프로젝트
- java
- 성적프로그램
- 정보처리기사
- git
- algorithms
- 뇌정리
- 필기
- 함수형 코딩
- post
- If
- 항해99
- 2020년 정보처리기사 4회
- Til
- hackerrank
- 코드숨
- 주간회고
- 2020년 일정
- 스터디
- sqldeveloper
- Jackson
- 2020년 제4회 정보처리기사 필기 문제 분석
- 책리뷰
Archives
- Today
- Total
조컴퓨터
9. Palindrome Number 본문

i) x<0일 경우, output: false
ii) x=0일 경우, output: true
iii) x>0일 경우, output: true OR false
iii)에서 x의 값을 1의 자리부터 순차적으로 추출한 다음
해당 값에 10을 곱하여 10의 자리로 올림
이 과정을 반복
class Solution {
public boolean isPalindrome(int x) {
if( x<0 ){
return false;
} else {
long ans=0, temp=x;
while( temp>=1 ){
ans = ans*10 + temp%10;
temp /= 10;
}
if( x==ans ){
return true;
}
return false;
}
}
}

해당 코딩의 효율은 좋지 않다.
리팩터링의 시간을 가져야 할 듯...
'LeetCode > Algorithms' 카테고리의 다른 글
*21. Merge Two Sorted Lists (0) | 2021.10.17 |
---|---|
*20. Valid Parentheses (0) | 2021.10.17 |
**14. Longest Common Prefix (0) | 2021.10.14 |
13. Roman to Integer (0) | 2021.10.13 |
1. Two Sum (0) | 2021.10.11 |