using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace First_week { public class StringUtils { public static bool IsPalindrome(string s) { if (string.IsNullOrEmpty(s)) return false; string cleaned = new string(s.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower(); string reversed = new string(cleaned.Reverse().ToArray()); return cleaned == reversed; } public static string ReverseWords(string sentence) { if (string.IsNullOrEmpty(sentence)) return sentence; var words = sentence.Split(' '); var reversedWords = words.Select(word => new string(word.Reverse().ToArray())); return string.Join(" ", reversedWords); } public static string RemovePunctuation(string s) { if (string.IsNullOrEmpty(s)) return s; return new string(s.Where(c => !char.IsPunctuation(c)).ToArray()); } public static bool IsAlphaNumeric(string s) { if (string.IsNullOrEmpty(s)) return false; return s.All(char.IsLetterOrDigit); } } }