JAVA Check Odd


  • 0
    Y
    public class Solution {
        public boolean canPermutePalindrome(String s) {
            int odd = 0;
            int[] count = new int[128];
            for(char ch: s.toCharArray()){
                count[ch]++;
                if(count[ch] % 2 == 0)
                    odd--;
                else
                    odd++;
            }
            
            return odd <= 1;
        }
    }

Log in to reply
 

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