C# Solution for Longest Palindrome Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this solution is similar to the previous one but uses an array ins
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this solution is similar to the previous one but uses an array instead of a HashMap to count character frequencies. This leverages the fact that we are dealing with a fixed set of characters (ASCII values for lowercase and uppercase English letters), making the array a simpler and potentially faster alternative\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tCounting Character Frequencies:\n\t\u2022\tUse an array of size 128 to count the occurrences of each character based on their ASCII values. This array covers all the required characters.\n2.\tConstructing the Palindrome:\n\t\u2022\tIterate through the array of character counts.\n\t\u2022\tIf a character count is even, it can be fully used in the palindrome.\n\t\u2022\tIf a character count is odd, use the even part of it (count - 1) for the palindrome and keep track of the fact that there is at least one character with an odd count.\n3.\tFinal Adjustment:\n\t\u2022\tIf there is at least one character with an odd count, add 1 to the length to account for the center character of the palindrome.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\u2022\tCounting Characters: O(n), where n is the length of the string. This is because we traverse the string once to count character frequencies.\n\u2022\tCalculating Length: O(1), since we iterate over a fixed-size array of 128 elements, which is constant time.\n\nOverall, the time complexity is O(n).\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(1), because we use a fixed-size array of 128 elements, which is constant space regardless of the input size.\n\n# Code\n```\npublic class Solution {\n    public int LongestPalindrome(string s) {\n        // Array to count occurrences of each character\n        int[] charCount = new int[128]; // ASCII characters\n        \n        // Count occurrences of each character\n        foreach (char c in s) {\n            charCount[c]++;\n        }\n        \n        int length = 0;\n        bool hasOddCount = false;\n        \n        // Iterate through the character counts\n        foreach (int count in charCount) {\n            if (count % 2 == 0) {\n                length += count;\n            } else {\n                length += count - 1;\n                hasOddCount = true;\n            }\n        }\n        \n        // If there was any character with an odd count, we can add one more character to the center of the palindrome\n        if (hasOddCount) {\n            length += 1;\n        }\n        \n        return length;\n    }\n}\n```
['C#']