티스토리 뷰
https://leetcode.com/problems/palindrome-number/
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
정수형 숫자가 회문인지 아닌지 판단하시오. 앞에서부터 읽어도 뒤에서부터 읽어도 같은 경우 회문인 숫자입니다.
Example 1:
Input: 121
Output: true
Example 2:
Example 2:
Input: -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
설명 : 왼쪽에서 오른쪽으로 읽을 때 -121. 오른쪽에서 왼쪽으로 읽을 때 121-. 그래서 회문이 아닙니다.
Example 3:
Input: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
설명 : 오른쪽에서 왼쪽으로 읽으면 01. 그래서 회문이 아닙니다.
Follow up:
Could you solve it without converting the integer to a string?
도전과제 : 숫자형을 문자형으로 바꾸지 않고 이 문제를 풀 수 있습니까?
문자형으로 변환을 하지 않고 푸는 것이 도전과제이므로 문자형으로 변환하면 쉽게 풀 수 있다는 것을 알 수 있다.
문자형으로 변환하여 풀기 :
숫자형 자체만으로도 푸는 것도 어렵지는 않다. 숫자를 반전시켜서 반전시키기 전의 값과 같으면 회문숫자이다.
숫자를 반전시키는 건 7.Reverse Integer 참조
'leetcode easy' 카테고리의 다른 글
7. Reverse Integer (0) | 2019.02.28 |
---|---|
1. Two Sum (0) | 2019.02.20 |
- Total
- Today
- Yesterday
- Python #Powertools
- multipleIntegrationFlow
- PostgreSQL #sequnceName
- logback #logstash #LoggingEventCompositeJsonEncoder #로그JSON
- excel table
- aws #aws region #aws credential #aws region provider #aws credential provier
- cannotResolveSymbol
- PostgreSQL #FOR UPDATE #SKIP LOCKED
- springintegration #파일감시 #디렉토리감시 #파일완료검사
- spring #redis #redis-cluster
- lombok #maven build #sym
- json
- QR코드읽기 #ReadQRCode
- Postgresql #MultiTruncate
- palindrome number
- leetcode
- yaml
- excel to markdown
- SnakeYAML
- AWS #X-Ray
- add two numbers
- spring-integration
- Two Sum
- 로그파일인덱스
- reverse integer
- Maven LF #메이븐 개행문자
- 로그테스트 #콘솔로그테스트 #System.out
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |