Palindrome Number
Updated
Problem statement
Given an integer x, return true if x is a palindrome, and false otherwise.
An integer is a palindrome when its decimal digits read the same from left to right and from right to left. A negative number is never a palindrome, because its minus sign has no match at the other end.
Follow-up: can you solve it without converting the integer to a string?
Function
isPalindrome(x: int) → booleanExamples
Example 1
x = 121return = trueRead from left to right, the digits are 1, 2, 1. Read from right to left, they are also 1, 2, 1. So 121 is a palindrome.
Example 2
x = -121return = falseFrom left to right the number reads -121. From right to left it reads 121-. These are different, so the answer is false.
Example 3
x = 10return = falseFrom right to left the number reads 01, which is not the same as 10. So the answer is false.
Constraints
-2^31 <= x <= 2^31 - 1
More Kotak Mahindra Bank interview questions
- Longest Common PrefixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Longest Consecutive SequencePHONE SCREEN · Seen Nov 2026
- Validate Binary Search TreePHONE SCREEN · Seen Nov 2026
- Roman to IntegerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Remove Duplicates From Sorted Array In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
- Best Time to Buy and Sell Stock IIONSITE INTERVIEW · Seen Nov 2026
- Maximum Non-Adjacent Coins in Two RowsONSITE INTERVIEW · Seen Oct 2026
- Search in Rotated Sorted ArrayONSITE INTERVIEW · Seen Oct 2026
- Find the Index of the First Occurrence in a StringONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Newton Square Root to a Guaranteed ToleranceSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Dice Sum That Is a Multiple of mSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions