[抄题]:

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. svn的使用流程

    一.安装: 1. 服务器端:VisualSVN_Server 2. 客户端:TortoiseSVN 二.使用VisualSVN Server建立版本库 1. 首先打开VisualSVN Server ...

  2. 【vs2013】使用VS2013打包程序

    如何用 VS 2013 打包 程序? 摘自:http://www.zhihu.com/question/25415940 更多请见摘自. 答案就在这里,想要你的exe独立运行在XP中:1.将平台工具集 ...

  3. ORMLite的使用

    首先需要下载core和android两个jar http://ormlite.com/releases/ 然后拷贝到libs文件夹下并且添加为库 具体的使用看标程: School.java packa ...

  4. 【转】WINSOCKET客户端编程以及JMETER外部调用

    1 public class SocketClient { 2 OutputStream clientout = null; 3 InputStream clienIn = null; 4 byte[ ...

  5. java代码反转toCharAT()的用法

    总结:反转注意for循环里面的变化 package clientFrame; //字符串反转 public class we { public static void main(String[] ar ...

  6. 登陆验证系统实例-三种(cookie,session,auth)

    登陆验证 因为http协议是无状态协议,但是我们有时候需要这个状态,这个状态就是标识 前端提交from表单,后端获取对应输入值,与数据库对比,由此对象设置一个标识,该对象 在别的视图的时候,有此标识, ...

  7. ORACLE GoldenGate在Windows与AIX平台ORACLE的单向、双向数据传输配置及其测试

    第1章...... GoldenGate概述 1.1         GoldenGate技术原理 1.2         GoldenGate可靠的复制 1.3         GoldenGate ...

  8. mac下自定义伪协议配置

    之前查了很多资料,最近也在挖掘研究这方面的漏洞. windows的很简单,在注册表配置就好了,但是mac os 是unix的,没有注册表这么一说. 但是发现腾讯等配置了自定义等协议,例如:tencen ...

  9. springboot成神之——springboot入门使用

    springboot创建webservice访问mysql(使用maven) 安装 起步 spring常用命令 spring常见注释 springboot入门级使用 配置你的pom.xml文件 配置文 ...

  10. 1.4 Application应用

    使用celery第一件要做的最为重要的事情是需要先创建一个Celery实例,我们一般叫做celery应用,或者更简单直接叫做一个app.app应用是我们使用celery所有功能的入口,比如创建任务,管 ...