Palindrome Permutation



@vinod23 ,@mrkingdom75 can you please explain how 'abcab' it can be a palindrome permutation?since a and b appears even time and c appear once which is fine but it is not palindrome anymore even though permutation is fine.

hi @ramsiddarth , it's same with my answer for @Nu1L 'aab' is not Palindrome but is Palindrome Permutation because 'aab' > 'aba',
So same with input 'abcab' is Palindrome Permutation because after you permute 'abcab' it becomes 'abcba' , and 'abcba' is Palindrome
Hope my answer can help you

@mrkingdom75 make sense so with even number of same character and one odd character we can say the string should be palindrome.

//Store all the values in map, now if it is a palindrome then all the char should have even number and only one can have odd depending upong the length of a string, if length is odd then there will be one element which will have odd count, if length is even then all char should have even length class Solution { public boolean canPermutePalindrome(String s) { Map<Character,Integer> map = new HashMap<>(); for (char ch : s.toCharArray()){ if (map.containsKey(ch)){ int temp = map.get(ch); map.put(ch,temp+1); }else map.put(ch,1); } boolean isValid = false; for (char ch : map.keySet()){ if (map.get(ch)%2==0) continue; if ((map.get(ch)%2==1)&&(isValid == true)){ return false; }else if (map.get(ch)%2==1){ isValid = true; continue; } } return true; } }