Given a string S which only contains lowercase alphabets. Find the length of the longest substring of S such that the characters in it can be rearranged to form a palindrome.
S = "aabe"
The substring "aab" can be rearranged to
"aba" which is the longest palindrome
possible for this String.
S = "adbabd"
The whole string “adbabd” can be
rearranged to form a palindromic substring.
One possible arrangement is "abddba".
Thus, output length of the string is 6.
You don't need to read input or print anything. Your task is to complete the function longestSubstring() which takes a String S as input and returns the length of largest possible Palindrome.
Expected Time Complexity: O(|S|*26) Expected Auxiliary Space: O(|S|*26)