Java Solution O(n) O(n)


#1
public class Solution {
    public int solve(String a) {
        HashMap<Character, Integer> hm = new HashMap<>();
        for(int i=0; i<a.length(); i++) {
            Character c=a.charAt(i);
            if(hm.containsKey(c))
                hm.put(c, hm.get(c)+1);
            else 
                hm.put(c, 1);
        }
        int flag=0;
        for(Map.Entry<Character, Integer> m : hm.entrySet())
            if((m.getValue()&1)==1)   flag++;
        return flag<2?1:0;
    }
}