public class Solution { public bool IsPalindrome(int x) { if (x < 0) { return false; } var str = x.ToString(); var list = new List<string>(); foreach (var c in str) { list.Add(c.ToString()); } var count = list.Count; for (int i = 0; i < list.Count; i++) { var n1 = list[i]; var n2 = list[list.Count - 1 - i]; if (n1 != n2) { return false; } if (i >= list.Count - 1 - i) { break; } } return true; } }
https://leetcode.com/problems/palindrome-number/#/description