Solution.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Solution : MonoBehaviour
{
public int x = 121;
void Start()
{
Debug.Log(IsPalindrome(x));
}
public bool IsPalindrome(int x)
{
if(x<0 || (x%10==0 && x!=0))
return false;
int reversedNum = 0;
while(x > reversedNum)
{
reversedNum = reversedNum * 10 + (x % 10);
x /= 10;
}
return x == reversedNum || x == reversedNum / 10;
}
}