Java Palindrome Rearranging
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static boolean palindromeRearranging(String inputString) {
Map<Character, Integer> counts = new HashMap<>();
for (char c : inputString.toCharArray()) {
counts.merge(c, 1, Integer::sum);
}
int oddCount = 0;
for (int v : counts.values()) {
if (v % 2 != 0) {
oddCount++;
}
}
return oddCount <= 1;
}
}
This counts character frequency and checks whether the string has the right number of odd counts to form a palindrome.