Palindrome Number
קל
שאלה מראיונות עבודה ממאגר שאלות של LeetCode שאלה מספר 9 נשאל ב: Google
Given an integer `x`, return `true` if `x` is a palindrome, and `false` otherwise.
פתרון קוד
JavaScript
Python
function isPalindrome(x) {
if (x < 0) return false;
let original = x;
let reversed = 0;
while (x > 0) {
reversed = reversed * 10 + (x % 10);
x = Math.floor(x / 10);
}
return reversed === original;
}הסבר וידאו כיצד לפתור את השאלה

לעבור את ראיון העבודה הבא שלך בהצלחה
קורס דיגיטלי מקיף עם +25 שיעורים מעשיים, כשעתיים של וידאו, וליווי של מראיין בכיר.