[抄题]:

Given a string, determine if a permutation of the string could form a palindrome.

For example,
"code" -> False, "aab" -> True, "carerac" -> True.

[暴力解法]:

时间分析:

空间分析:

[优化后]:

时间分析:

空间分析:

[奇葩输出条件]:

[奇葩corner case]:

[思维问题]:

[一句话思路]:

hashset还有.remove()方法

[输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入):

[画图]:

[一刷]:

[二刷]:

[三刷]:

[四刷]:

[五刷]:

[五分钟肉眼debug的结果]:

[总结]:

[复杂度]:Time complexity: O(n) Space complexity: O(n)

[英文数据结构或算法,为什么不用别的数据结构或算法]:

[关键模板化代码]:

[其他解法]:

[Follow Up]:

[LC给出的题目变变变]:

[代码风格] :

class Solution {
public boolean canPermutePalindrome(String s) {
//cc
if (s.length() == 0) {
return true;
} //ini: set
Set set = new HashSet(); //for loop: +-
for (char c : s.toCharArray()) {
if (set.contains(c)) {
set.remove(c);
}else {
set.add(c);
}
} //return set.size()
return (set.size() == 0) || (set.size() == 1);
}
}

266. Palindrome Permutation 重新排列后是否对称的更多相关文章

  1. leetcode 266.Palindrome Permutation 、267.Palindrome Permutation II

    266.Palindrome Permutation https://www.cnblogs.com/grandyang/p/5223238.html 判断一个字符串的全排列能否形成一个回文串. 能组 ...

  2. [LeetCode] 266. Palindrome Permutation 回文全排列

    Given a string, determine if a permutation of the string could form a palindrome. Example 1: Input: ...

  3. LeetCode 266. Palindrome Permutation (回文排列)$

    Given a string, determine if a permutation of the string could form a palindrome. For example," ...

  4. 【LeetCode】266. Palindrome Permutation 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 日期 题目地址:https://leetcode ...

  5. 266. Palindrome Permutation

    题目: Given a string, determine if a permutation of the string could form a palindrome. For example,&q ...

  6. [LeetCode#266] Palindrome Permutation

    Problem: Given a string, determine if a permutation of the string could form a palindrome. For examp ...

  7. 【leetcode】266. Palindrome Permutation

    原题 Given a string, determine if a permutation of the string could form a palindrome. For example, &q ...

  8. [LeetCode] 267. Palindrome Permutation II 回文全排列 II

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  9. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

随机推荐

  1. IronPython之基本类型

    通过下图展现IronPython的基本类型,便于理解和记忆. 基本数据类型 数据类型 类型 示例 备注 Byte string str ‘hello’ “hello” “””hello””” ‘’’h ...

  2. STM32F103外部晶振由8M变为12M

    STM32官方提供的库文件中,HSE(外部高速时钟)默认为8MHz,最高主频为8*9=72MHz,如果将HSE变为12MHz,不修改库文件的话,最高主频则变为12*9=108MHz,最典型的问题就是U ...

  3. 获取sonar扫描结果

    api通过抓包获取 java 1.get和post方法 package com.tools.httpUtil; import java.io.BufferedReader; import java.i ...

  4. CodeReview是开发中的重要一个环节,整理了一些关于jupiter for java

    什么是代码评审(CodeReview)? 代码评审也称代码复查,是指通过阅读代码来检查源代码与编码标准的符合性以及代码质量的活动. Jupiter提供了代码行级别的评审批注功能,方便评审参与人了解具体 ...

  5. JMS可靠性机制

    1. 消息接收确认 JMS消息只有在被确认之后,才认为已经被成功的消费了,消息的成功消费通常包含三个阶段:客户接收消息,客户处理消息和消息被确认 在事务性会话中,当一个事务被提交的时候,确认自动发生. ...

  6. 简述FPGA时序约束理论

    FPGA时序约束简介. 时序约束的场景: 在简单电路中,当频率较低时,数字信号的边沿时间可以忽略时,无需考虑时序约束.但在复杂电路中,为了减少系统中各部分延时,使系统协同工作,提高运行频率,需要进行时 ...

  7. ALTERA DDRII IP核使用

    提到DDRII,大家应该都不陌生,DDRII SDRAM是第二代双倍速率同步动态RAM.今天小编给大家介绍一下QUARTUS II 下调用DDRII软核. 新建QUARTUSII工程之后,在tool下 ...

  8. RHEL6 64位ASM方式安装oracle 11gR2(二)

    本文转载自:http://vnimos.blog.51cto.com/2014866/1221377 三.安装数据库软件 1 2 3 4 5 6 7 8 # unzip -d /stage/ linu ...

  9. .Net上传文件超过了最大请求长度

    错误消息:超过了最大请求长度    错误原因:asp.net默认最大上传文件大小为4M,运行超时时间为90S. 修改web.config文件可以改变这个默认值为 <configuration&g ...

  10. npm run dev报错,events.js:160 throw er; // Unhandled 'error' event

    错误代码如下: vue-project@1.0.0 dev E:MySoftwaretestGitwebpackvue-projectnode build/dev-server.js "80 ...