bool palindromeRearranging(string inputString) { if (inputString.Length % 2 == 0 && inputString.Distinct().Any(c => inputString.Count(x => x == c) % 2 != 0)) return false; if (inputString.Length % 2 == 1) { int count = 0; foreach (var c in inputString.Distinct()) { if (inputString.Count(x => x == c) % 2 != 0) count++; if (count > 1) return false; } } return true; }
Previous Next