409. Longest Palindrome
来源:互联网 发布:淘宝图片多少像素 编辑:程序博客网 时间:2024/04/30 04:12
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.
This is case sensitive, for example “Aa” is not considered a palindrome here.
Note:
Assume the length of given string will not exceed 1,010.
Example:
Input:
“abccccdd”
Output:
7
Explanation:
One longest palindrome that can be built is “dccaccd”, whose length is 7.
class Solution {public: int longestPalindrome(string s) { map<char,int> maps; map<char,int>::iterator it; int count=0; for(char i:s) { maps[i]++; } for(it=maps.begin();it!=maps.end();it++) { while(it->second>1) { count+=2; it->second-=2; } } int res=0; for(it=maps.begin();it!=maps.end();it++) { if(it->second>0) { res++; } } if(res>0) count++; return count; }};
0 0
- 【Leetcode】409. Longest Palindrome
- 409. Longest Palindrome
- 409. Longest Palindrome
- [LeetCode]409. Longest Palindrome
- 409. Longest Palindrome
- 409. Longest Palindrome
- 409. Longest Palindrome
- LeetCode 409. Longest Palindrome
- 409. Longest Palindrome
- [LeetCode]--409. Longest Palindrome
- leetcode 409. Longest Palindrome
- LeetCode 409. Longest Palindrome
- 409. Longest Palindrome
- LeetCode 409. Longest Palindrome
- 409. Longest Palindrome
- 409. Longest Palindrome
- 409. Longest Palindrome
- 409. Longest Palindrome
- 二叉树中的先序遍历、中序遍历和后序遍历关系
- 什么是ActiveRecord
- Jsp九大内置对象
- cocos2d - JS 进阶主题 call() 、apply() 和 bind() 解析
- 推荐算法
- 409. Longest Palindrome
- 排序
- nginx root问题
- matlab的mbuild和mex之未找到支持的编译器或 SDK 解决方法--整理
- Banner无限轮播
- php mysql localhost,127.0.0.1和ip区别
- java.io.File mkdir() 和 mkdirs()的差别
- [RK3399] PWM Backlight 驱动分析
- 浅析VO、DTO、DO、PO的概念、区别和用处