AC Java Solution


  • 0
    Q
    public class Solution {
        public boolean canPermutePalindrome(String s) {
            if(s == null || s.length() == 0) return false;
            int[] a = new int[256];
            for(int i = 0; i < s.length(); i++) {
                a[s.charAt(i)]++;
            }
            boolean flag = false;
            for(int i = 0; i < 256; i++) {
                if(a[i] % 2 == 1) {
                    if(flag) return false;
                    flag = true;
                }
            }
            return true;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.