-
Notifications
You must be signed in to change notification settings - Fork 378
Description
LeetCode Username
Henry_777
Problem Number, Title, and Link
- Palindrome Number https://leetcode.com/problems/palindrome-number/
Bug Category
Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)
Bug Description
The current set of provided examples in the problem statement only covers:
-
A positive palindrome (121)
-
A negative number (-121)
-
A non-palindrome ending in zero (10)
While these are useful, some important edge cases are missing from the examples section. This can cause confusion for beginners who might not realize these cases are valid inputs according to the constraints.
Specifically missing:
- Single-digit numbers (0–9) — these are trivially palindromes, but not demonstrated in examples.
- Large palindromes near the upper limit of int (e.g., 2147447412) — useful for stress-testing integer reversal approaches.
Language Used for Code
C
Code used for Submit/Run operation
#include <stdbool.h>
bool isPalindrome(int x) {
if (x < 0 || (x != 0 && x % 10 == 0)) return false;
int rev = 0;
while (x > rev) {
rev = rev * 10 + x % 10;
x /= 10;
}
return (x == rev || x == rev / 10);
}
Expected behavior
I expected the problem statement to explicitly demonstrate that:
x = 0 should return true.
x = 7 should return true.
x = 2147447412 should return true.
These would make the examples more comprehensive and prevent confusion for new problem-solvers.
Screenshots
No response
Additional context
The online judge already handles these cases correctly in hidden tests, but adding them explicitly in the examples section would make the problem statement clearer and more beginner-friendly.