Question: I need explanation for this C# code and also add commend for each line in the code the code check if the string is a
I need explanation for this C# code and also add commend for each line in the code
the code check if the string is a permutation of a palindrome or not.
static bool isPalinPermutatble(String str) { int [] arr = new int[256]; for (int i = 0; i < arr.Length; i++) { arr[i] = 0; } for (int j = 0; j < str.Length; j++) { if (str[j] == ' ') { arr[(int)(str[j])]++; } } int odd = 0; foreach (int a in arr) { if (a % 2 != 0) odd++; }
if (odd <= 1) return true; else return false;
}
static void Main(string[] args) {
Console.WriteLine("Enter a string: "); string str = Console.ReadLine(); Console.WriteLine(isPalinPermutatble(str)); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
