【leetcode】409. Longest Palindrome
problem
solution1:
class Solution {
public:
int longestPalindrome(string s) {
map<char, int> temp;
for(auto it:s) temp[it]++;
int even = , odd = , mid=false;
for(auto it=temp.begin(); it!=temp.end(); ++it)
{
if(it->second % ==) even+=it->second;
else
{
mid = true;
odd += it->second-;
}
}
return even+(mid?(odd+):);
}
};
参考
1. Leetcode_409. Longest Palindrome;
完
【leetcode】409. Longest Palindrome的更多相关文章
- 【LeetCode】409. Longest Palindrome 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:字典统计次数 方法二:HashSet 方法三 ...
- 【LeetCode】522. Longest Uncommon Subsequence II 解题报告(Python)
[LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemin ...
- 【LeetCode】9、Palindrome Number(回文数)
题目等级:Easy 题目描述: Determine whether an integer is a palindrome. An integer is a palindrome when it rea ...
- 【LeetCode】159. Longest Substring with At Most Two Distinct Characters
Difficulty: Hard More:[目录]LeetCode Java实现 Description Given a string S, find the length of the long ...
- 【LeetCode】680. Valid Palindrome II
Difficulty:easy More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/valid-palindrome ...
- 【leetcode❤python】409. Longest Palindrome
#-*- coding: UTF-8 -*- from collections import Counterclass Solution(object): def longestPalindro ...
- 【leetcode】1147. Longest Chunked Palindrome Decomposition
题目如下: Return the largest possible k such that there exists a_1, a_2, ..., a_k such that: Each a_i is ...
- 【leetcode】300.Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...
- 【LeetCode】214. Shortest Palindrome 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 前缀是否回文 判断前缀 相似题目 参考资料 日期 题 ...
随机推荐
- python, 在信用评级中,计算KS statistic值
# -*- coding: utf-8 -*- import pandas as pd from sklearn.grid_search import GridSearchCV from sklear ...
- spring cloud jwt用户鉴权及服务鉴权
用户鉴权 客户端请求服务时,根据提交的token获取用户信息,看是否有用户信息及用户信息是否正确 服务鉴权 微服务中,一般有多个服务,服务与服务之间相互调用时,有的服务接口比较敏感,比如资金服务,不允 ...
- js如何返回两个数的商的整数和余数部分?
js中,如何返回两个数的商的整数和余数部分? 如: num1:100 ,num2:12 var num = parseFloat(100/12); //值: 8.333333333333334 那么如 ...
- ubuntu12下安装eclipse+pydev +1搜索命令+kill指定进程
sudo apt-get install eclipse 下载pydev for eclipse 2.8,如果是jre6 解压. sudo nautilus 复制相应的文件夹到/usr/share/e ...
- mac nginx+php-fpm配置(安装过后nginx后访问php文件下载,访问php文件请求200显示空白页面)
访问php文件下载是因为没配置php-fpm 两个问题主要都是nginx.conf配置的问题: /usr/local/etc/nginx/nginx.conf server { listen 8 ...
- 1-MAVEN 仓库
本地资源库 MAVEN的本地资源库是用来存储所有项目的依赖关系(插件和其他文件,这个文件被MAVEN 下载到本地文件中.) 可以通过修改MAVEN安装目录下conf/setting.xml配置 ...
- printf以%d形式输出浮点数的问题
若运行时从键盘上输入9876543210l,则下面程序的输出结果是 int main(){ int a;float b,c; scanf("%2d%3f%4f",&a,&a ...
- Uva LA 3902 - Network 树形DP 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 为什么IT运维工程师要学习Linux系统
不论你是否知道,其实你每天都在使用Linux.每次你访问微博.百度甚至是一些小电影网站,你的客户端(浏览器)都在与运行在Linux系统上的服务端程序进行通讯,大多数的电子设备,例如数位录像机.飞机.自 ...
- Docker容器使用jenkins部署web项目--总结(二)
(1)需要安装Docker容器,在Docker容器内安装jenkins,gogs,tomcat. 新建maven项目,添加findbugs plugin. 使用docker启动jenkins,go ...