Given a string, determine if a permutation of the string could form a palindrome.

For example,
"code" -> False, "aab" -> True, "carerac" -> True.

要点:学习如何iterate一个unordered_map。

 class Solution {
public:
bool canPermutePalindrome(string s) {
unordered_map<char, int> dict;
for (int i = , n = s.size(); i < n; i++) {
if (dict.count(s[i]) == )
dict.insert(make_pair(s[i], ));
else dict[s[i]]++;
}
int oddCount = ;
for (auto it = dict.begin(); it != dict.end(); it++) {
if (it->second % ) oddCount++;
if (oddCount > ) return false;
}
return true;
}
};

最新文章

  1. ASP.NET MVC Model验证(三)
  2. Dynamics CRM 2015-如何修改Optionset Default Value
  3. MontageJS:构建现代 Web App 的 HTML5 框架
  4. cpg数据库处理_找到未提取的pdf
  5. 【001:Tomcat搭建简单文件服务器】
  6. HTTP 头部详细解释
  7. poj 2236 并查集
  8. PO_PO系列 - 收货管理分析(案例)
  9. iOS应用如何支持IPV6-b
  10. shell基础——变量定义
  11. innodb更改行格式,系统盘占用急剧升高
  12. B树和B+树的总结
  13. Python中使用hashlib进行加密的简单使用
  14. 3、java面向对象编程
  15. iOS逆向工程概述(转)
  16. 十分钟搞定 pandas
  17. Nginx.conf配置文件参数说明与优化
  18. 微信小程序之---- 数据处理
  19. C#泛型的学习
  20. 2018-2019-2 20175230 实验三《Java面向对象程序设计》实验报告

热门文章

  1. appium+python的APP自动化(2)
  2. Ubuntu15.04 python升级到python-3.6.x
  3. Leetcode 662.二叉树最大宽度
  4. HDU 4346 The Beautiful Road ( 反向考虑 思路题 )
  5. UVa 1445 - Cubist Artwork
  6. iPhone新建项目不能全屏
  7. Python中的多线程编程,线程安全与锁(一)
  8. 【bzoj2306】[Ctsc2011]幸福路径 倍增Floyd
  9. P2029 跳舞
  10. [洛谷P2634][国家集训队]聪聪可可