• 문제 링크
Palindrome Number - LeetCode
Can you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Ex
leetcode.com
• 풀이 코드
public class Solution {
public boolean isPalindrome(int x) {
if (x < 0) return false;
int sum = 0, n = x;
do sum = sum * 10 + n % 10; while ((n /= 10) > 0);
return x == sum;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 12. Integer to Roman - Java (0) | 2026.05.09 |
|---|---|
| [LeetCode] 11. Container With Most Water - Java (0) | 2026.05.08 |
| [LeetCode] 3. Longest Substring Without Repeating Characters - Java (0) | 2026.05.06 |
| [LeetCode] 2. Add Two Numbers - Java (0) | 2026.05.05 |
| [LeetCode] 1. Two Sum - Java (0) | 2026.05.04 |
댓글