SHARE
TWEET

Untitled

a guest Sep 13th, 2017 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2.   // O(n) O(n)
  3.     public boolean canPermutePalindrome(String s) {
  4.         HashSet<Character> set = new HashSet<Character>();
  5.        
  6.         for (Character c : s.toCharArray()) {
  7.             if (!set.add(c)) {
  8.                 set.remove(c);
  9.             }
  10.         }
  11.        
  12.         return set.size() < 2;
  13.     }
  14. }
RAW Paste Data
Top