problem

409. Longest Palindrome

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的更多相关文章

  1. 【LeetCode】409. Longest Palindrome 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:字典统计次数 方法二:HashSet 方法三 ...

  2. 【LeetCode】522. Longest Uncommon Subsequence II 解题报告(Python)

    [LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemin ...

  3. 【LeetCode】9、Palindrome Number(回文数)

    题目等级:Easy 题目描述: Determine whether an integer is a palindrome. An integer is a palindrome when it rea ...

  4. 【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 ...

  5. 【LeetCode】680. Valid Palindrome II

    Difficulty:easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/valid-palindrome ...

  6. 【leetcode❤python】409. Longest Palindrome

    #-*- coding: UTF-8 -*- from collections import Counterclass Solution(object):    def longestPalindro ...

  7. 【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 ...

  8. 【leetcode】300.Longest Increasing Subsequence

    Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...

  9. 【LeetCode】214. Shortest Palindrome 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 前缀是否回文 判断前缀 相似题目 参考资料 日期 题 ...

随机推荐

  1. NOSQL -- mongoDB的了解与安装(Wins10)

    NOSQL -- mongoDB的了解与安装 首先看看什么是nosql: 我的理解:非关系型数据库,大多是以map形式存储,map<key,value>,适合存储,查询.redis也是no ...

  2. Mysql锁(翻译)

    内容主要是对mysql文档的翻译. 1. shared(s) 共享锁2. exclusive(x) 排它锁 innodb的s锁和x锁是行级锁.事务T1获得s锁,事务T2仍然可以获得s锁.事务T1获得x ...

  3. weblogic补丁安装失败(Patch B25A is mutually exclusive and cannot coexist with patch(es): UIAL)

    由于曝出漏洞(CVE-2017-3248)需要将weblogic补丁更新至B25A,但是出现报错.如下: Conflict(s) detected - resolve conflict conditi ...

  4. python3练习-装饰器

    在廖雪峰的官方网站学习装饰器章节时,初步理解类似与面向切面编程.记录一下自己的课后习题解法. 问题: 请编写一个decorator,能在函数调用的前后打印出'begin call'和'end call ...

  5. mvc4自定义辅助器方法的学习

    1.什么是辅助器 它们可以对代码块和标记进行打包,以便能够在mvc框架应用程序中重用.可以理解成编写在页面上的C#代码(方法). 2 .自定义辅助器 创建“基本”的mvc示例,并创建Basic控制器, ...

  6. 转 /etc/ld.so.conf.d/目录下文件的作用

    在了解/etc/ld.so.conf.d/目录下文件的作用之前,先介绍下程序运行是加载动态库的几种方法:第一种,通过ldconfig命令    ldconfig命令的用途, 主要是在默认搜寻目录(/l ...

  7. 研究Duilib的实现结构

    第一步:调用RegisterClassEx(): 第二步:调用CreateWindowEx() 第三步:调用ShowWindow(),同时启动消息循环 说明: 1.RegisterClass,Regi ...

  8. laravel处理菜单保持的方法:

    <!-- 左侧菜单区域 --> <div class="col-md-3"> @section('leftmenu') <div class=&quo ...

  9. flask-admin有用的例子

    flask-admin主页: https://github.com/flask-admin/flask-admin flask-admin克隆地址: https://github.com/flask- ...

  10. 单元测试模拟-moq

    1.moq 支持 net core 2.moq 通过一个接口类型 可以产生一个新的类 3.举例 //define interface to be mocked public interface ITe ...