Note:- Since the question didn't mentioned that to solve it without type-casting the value of n from integer to string, I tried this method.
- Time Complexity:- O(n)
- Space Complexity:- 0(n)
bool palindrome(int n) {
// Write your code here
while(n>=0){
string str= to_string(n); if(str==string(str.rbegin(), str.rend())) return true;
else return false;
}
}