
g0001_0100.s0009_palindrome_number.Solution.cs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
namespace LeetCodeNet.G0001_0100.S0009_palindrome_number {
// #Easy #Math #Udemy_Integers #2023_12_22_Time_42_ms_(34.61%)_Space_31_MB_(36.04%)
public class Solution {
public bool IsPalindrome(int x) {
if (x < 0) {
return false;
}
int rev = 0;
int localX = x;
while (localX > 0) {
rev *= 10;
rev += localX % 10;
localX /= 10;
}
return rev == x;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy