Skip to content

Instantly share code, notes, and snippets.

@d4vsanchez
d4vsanchez / leetcode_9_palindrome_number.rs
Created May 11, 2024 14:38
Solution for the "9. Palindrome Number" problem from LeetCode
impl Solution {
pub fn is_palindrome(x: i32) -> bool {
if x < 0 {
return false;
}
let mut x_copy = x;
let mut reverse: i32 = 0;
while x_copy > 0 {
reverse = (reverse * 10) + (x_copy % 10);