409. Longest Palindrome

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.

刚开始用hashmap 发现总是过不了那个变态testcase。 于是看了大神代码,用set 统计


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 背景 一年多以前我在知乎上答了有关LeetCode的问题, 分享了一些自己做题目的经验。 张土汪:刷leetcod...
    土汪阅读 12,768评论 0 33
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,811评论 0 23
  • 这几天总是在上课时时不时的拿出手机看看,,所以就今天开始每次上重要的课时就关机,专心上课,效果还是不错的以后继续这...
    雷帅帅阅读 164评论 0 0
  • 就像那片叶子始终找不到归宿,我似乎一直在迷茫。 我怎么了?只是太阳不太亮了,星星也好像消失了,那又怎样。旧巷里的猫...
    草莓怪阅读 281评论 0 1
  • 西汉长信宫灯,中国汉代青铜器,1968年于河北省满城县出土。 长信宫灯高48厘米,宫女高44.5厘米,重15.85...
    llllllHllllll阅读 216评论 0 1