LeetCode in C# | 9. Palindrome Number

preview_player
Показать описание


In this video I went through the ninth LeetCode challenge called Palindrome Number. This challenge is by far the easiest one so far.

Рекомендации по теме
Комментарии
Автор

I couldn't figure this one out. Thanks for the video.

rengokuxx
Автор

Hey, your solution is amazing, but I couldn't understand why do we have to divide 2 after the .Length one?

faust
Автор

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter num: ");
int n =

if (n < 0)
{
Console.WriteLine("Higher is requiered");
}
else
{
string test = n.ToString();
for (int i = 0; i < test.Length / 2; i++)
{
if (test[i] != test[test.Length - 1 - i])
{
Console.WriteLine("Not a palindrome");
}
else
{

}
}
}

}

}
}

kvelez