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. 利用神经网络进行网络流量识别——特征提取的方法是(1)直接原始报文提取前24字节,24个报文组成596像素图像CNN识别;或者直接去掉header后payload的前1024字节(2)传输报文的大小分布特征;也有加入时序结合LSTM后的CNN综合模型

    国外的文献汇总: <Network Traffic Classification via Neural Networks>使用的是全连接网络,传统机器学习特征工程的技术.top10特征如下 ...

  2. Linux查看操作系统版本命令

    有时候比如在决定下载软件版本的时候,我们需要确定当前系统的位数和发行版版本. 命令 作用 适用说明 uname -a 显示Linux内核版本和位数 通用,推荐 cat /proc/version 显示 ...

  3. ssh和ssl的联系和区别

    ssh:Secure Shell,安全Shell,是一个软件,处于应用层旨在取代明文通信的telnet:对应的开源实现程序是openssh. ssl:Secure Sockets Layer,安全套接 ...

  4. 使用Swagger2构建强大的RESTful API文档(2)(二十三)

    添加文档内容 在完成了上述配置后,其实已经可以生产文档内容,但是这样的文档主要针对请求本身,而描述主要来源于函数等命名产生,对用户并不友好,我们通常需要自己增加一些说明来丰富文档内容.如下所示,我们通 ...

  5. SpringBoot 配置文件存放位置及读取顺序

    SpringBoot配置文件可以使用yml格式和properties格式 分别的默认命名为:application.yml.application.properties 存放目录 SpringBoot ...

  6. swagger注释@API详细说明

    swagger是当前最好用的Restful  API文档生成的开源项目,通过swagger-spring项目实现了springMVC框架的无缝集成功能,方便生成restful风格的接口文档, 同时,s ...

  7. 转 举例说明使用MATLAB Coder从MATLAB生成C/C++代码步骤

    MATLAB Coder可以从MATLAB代码生成独立的.可读性强.可移植的C/C++代码. http://www.mathworks.cn/products/matlab-coder/ 使用MATL ...

  8. 逆袭之旅DAY15.东软实训.Oracle.约束、序列、视图、索引、用户管理、角色

    2018-07-11  08:26:00 有某个学生运动会比赛信息的数据库,保存了如下的表: 运动员sporter表:(运动员编号sporterid,运动员姓名name,运动员性别sex,所属系dep ...

  9. laravel中的登录页面逻辑

    <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades ...

  10. bzoj4698

    题解: 后缀数组 对所有序列差分一下 公共串的长度+1就是答案了 二分 扫一遍height即可,.. 代码: #include <bits/stdc++.h> using namespac ...