Palindrome Permutation
来源:互联网 发布:在淘宝上怎么买盗版书 编辑:程序博客网 时间:2024/05/16 17:00
public class Solution { public boolean canPermutePalindrome(String s) { if (s == null || s.length() < 2) { return true; } Map<Character, Boolean> map = new HashMap<>(); int oddCount = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (!map.containsKey(c)) { map.put(c, false); oddCount++; } else { if (map.get(c)) { map.put(c, false); oddCount++; } else { map.put(c, true); oddCount--; } } } boolean evenStr = s.length() % 2 == 0; if (evenStr) { if (oddCount == 0) { return true; } else { return false; } } else { if (oddCount == 1) { return true; } else { return false; } } }}
0 0
- Palindrome Permutation
- Palindrome Permutation
- Palindrome Permutation
- Leetcode: Palindrome Permutation
- *LeetCode-Palindrome Permutation
- [LeetCode 266]Palindrome Permutation
- 1.4 Palindrome Permutation
- 266 Palindrome Permutation
- [LeetCode266]Palindrome Permutation
- [LeetCode267]Palindrome Permutation II
- Leetcode - 266. Palindrome Permutation
- Leetcode266 Palindrome Permutation
- [Leetcode 266] Palindrome Permutation
- LeetCode 266. Palindrome Permutation
- Palindrome Permutation II
- 266. Palindrome Permutation
- Palindrome Permutation II
- Palindrome Permutation II
- 用vbs 将有序文件转换为有序文件
- 【慕课学习】《JavaScript深入浅出》——语句
- Android多线程操作——线程池管理综述
- 欢迎使用CSDN-markdown编辑器
- Min Stack
- Palindrome Permutation
- 让孩子一生不后悔
- 教学引导师培训
- Eclipse中,No compiler is provided in this environment. Perhaps you are running on a JRE rather than a
- 搭建Android Studio2.1配HTC One M8做测试环境
- String to Integer (atoi)
- 第49课:Spark中的新解析引擎Catalyst源码Optimizer彻底详解.
- Google百分比布局支持库----让屏幕适配更简单
- 进程的概念&&进程的描述&&进程控制块(task_struct)