diff --git a/.idea/.idea.Leetcode/.idea/workspace.xml b/.idea/.idea.Leetcode/.idea/workspace.xml
index 34f7850..b94eece 100644
--- a/.idea/.idea.Leetcode/.idea/workspace.xml
+++ b/.idea/.idea.Leetcode/.idea/workspace.xml
@@ -88,9 +88,9 @@
-
-
-
+
+
+
@@ -128,6 +128,7 @@
"keyToString": {
".NET Project.14. Longest Common Prefix.executor": "Run",
".NET Project.150. Evaluate Reverse Polish Notation.executor": "Run",
+ ".NET Project.9. Palindrome Number.executor": "Run",
"ASKED_ADD_EXTERNAL_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
@@ -150,7 +151,7 @@
]
}
}]]>
-
+
@@ -1645,8 +1646,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1662,7 +1682,7 @@
1678030074860
-
+
diff --git a/9. Palindrome Number/9. Palindrome Number.csproj b/9. Palindrome Number/9. Palindrome Number.csproj
new file mode 100644
index 0000000..67b341f
--- /dev/null
+++ b/9. Palindrome Number/9. Palindrome Number.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ _9._Palindrome_Number
+ enable
+ enable
+
+
+
diff --git a/9. Palindrome Number/Program.cs b/9. Palindrome Number/Program.cs
new file mode 100644
index 0000000..ee812bf
--- /dev/null
+++ b/9. Palindrome Number/Program.cs
@@ -0,0 +1,6 @@
+// See https://aka.ms/new-console-template for more information
+
+using _9._Palindrome_Number;
+
+var sol = new Solution();
+Console.WriteLine(sol.IsPalindrome(0));
\ No newline at end of file
diff --git a/9. Palindrome Number/Solution.cs b/9. Palindrome Number/Solution.cs
new file mode 100644
index 0000000..80222dd
--- /dev/null
+++ b/9. Palindrome Number/Solution.cs
@@ -0,0 +1,25 @@
+namespace _9._Palindrome_Number;
+
+public class Solution
+{
+ public bool IsPalindrome(int x)
+ {
+ if (x < 0)
+ return false;
+ if (x < 10)
+ return true;
+ List digits = new List(32);
+ while (x != 0)
+ {
+ digits.Add((byte)(x%10));
+ x /= 10;
+ }
+
+ int half = digits.Count / 2;
+ for (int i = 0; i < half; i++)
+ if (digits[i] != digits[digits.Count - 1 - i])
+ return false;
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Leetcode.sln b/Leetcode.sln
index 06bdebe..ee121b5 100644
--- a/Leetcode.sln
+++ b/Leetcode.sln
@@ -169,6 +169,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "14. Longest Common Prefix",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "150. Evaluate Reverse Polish Notation", "150. Evaluate Reverse Polish Notation\150. Evaluate Reverse Polish Notation.csproj", "{10A95EED-FD1D-40E7-B9E0-2DD48BE05AB9}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "9. Palindrome Number", "9. Palindrome Number\9. Palindrome Number.csproj", "{1397373A-47E9-4E22-8FE5-82376C7FACA1}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -507,6 +509,10 @@ Global
{10A95EED-FD1D-40E7-B9E0-2DD48BE05AB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10A95EED-FD1D-40E7-B9E0-2DD48BE05AB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10A95EED-FD1D-40E7-B9E0-2DD48BE05AB9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1397373A-47E9-4E22-8FE5-82376C7FACA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1397373A-47E9-4E22-8FE5-82376C7FACA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1397373A-47E9-4E22-8FE5-82376C7FACA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1397373A-47E9-4E22-8FE5-82376C7FACA1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE