uber电面面经【一亩三分地论坛面经版】 - Powered by Discuz!
1. 给定一个string,判断能否用这个string来组成一个palindrome。e.g. 'uber' --> False, 'aab' --> True, 'carecra' --> True
2. Follow up: 给出所有能够组成的palindrome,因为时间原因可以不用担心duplicates。(potential follow up就是去重了)
Leetcode
LeetCode [266] Palindrome Permutation
Read full article from uber电面面经【一亩三分地论坛面经版】 - Powered by Discuz!
1. 给定一个string,判断能否用这个string来组成一个palindrome。e.g. 'uber' --> False, 'aab' --> True, 'carecra' --> True
2. Follow up: 给出所有能够组成的palindrome,因为时间原因可以不用担心duplicates。(potential follow up就是去重了)
Leetcode
LeetCode [266] Palindrome Permutation
public boolean checkPermutationPalindrome(String input){
Set hashSet = new HashSet<Character>();
for(int i=0; i<input.length(); i++){
if(hashSet.contains(input.charAt(i)))
hashSet.remove(input.charAt(i));
else
hashSet.add(input.charAt(i));
}
if(hashSet.size() <= 1)
return true;
else
return false;
}
LeetCode [267] Palindrome Permutation IIRead full article from uber电面面经【一亩三分地论坛面经版】 - Powered by Discuz!