266. Palindrome Permutation 重新排列后是否对称
[抄题]:
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 重新排列后是否对称的更多相关文章
- leetcode 266.Palindrome Permutation 、267.Palindrome Permutation II
266.Palindrome Permutation https://www.cnblogs.com/grandyang/p/5223238.html 判断一个字符串的全排列能否形成一个回文串. 能组 ...
- [LeetCode] 266. Palindrome Permutation 回文全排列
Given a string, determine if a permutation of the string could form a palindrome. Example 1: Input: ...
- LeetCode 266. Palindrome Permutation (回文排列)$
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- 【LeetCode】266. Palindrome Permutation 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 日期 题目地址:https://leetcode ...
- 266. Palindrome Permutation
题目: Given a string, determine if a permutation of the string could form a palindrome. For example,&q ...
- [LeetCode#266] Palindrome Permutation
Problem: Given a string, determine if a permutation of the string could form a palindrome. For examp ...
- 【leetcode】266. Palindrome Permutation
原题 Given a string, determine if a permutation of the string could form a palindrome. For example, &q ...
- [LeetCode] 267. Palindrome Permutation II 回文全排列 II
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
- [LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
随机推荐
- Linux paste 命令
Linux paste命令用于合并文件的列. paste指令会把每个文件以列对列的方式,一列列地加以合并. 语法 paste [-s][-d <间隔字符>][--help][--versi ...
- 深入理解java虚拟机-第七章
第7章 虚拟机类加载机制 类的加载的时机 加载 Loading, 连接 Linking(验证 Verfiication, 准备Preparation, 解析 Resolution) 初始化 Initi ...
- 安装g++,在centos上执行yum -y install gcc gcc-c++ libstdc++-devel
Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: mirrors.1 ...
- linux操作系统安全防护
Linux系统攻防对抗实践 一.实践内容 在Metasploit渗透攻击框架软件中寻找一个针对Linux系统服务的渗透攻击模块,在网络安全攻防实验环境中部署有漏洞的环境(如渗透利用第三方网络服务,需要 ...
- verilog中function的使用
函数的功能和任务的功能类似,但二者还存在很大的不同.在 Verilog HDL 语法中也存在函数的定义和调用. 1.函数的定义 函数通过关键词 function 和 endfunction 定义,不允 ...
- AbstractIdleService
该类有一个startup和shutdown方法,启动此服务或者结束此服务的时候可以调用. Runtime.getRuntime().addShutdownHook(new Thread() {@Ove ...
- MTK驱动移植相关路径
转自:http://blog.csdn.net/yicao821/article/details/52314578 一.Flash兼容 bootable/bootloader/preloader/to ...
- laravel 网站速率优化
https://segmentfault.com/a/1190000009954966
- 蓝桥杯 算法训练 ALGO-21 装箱问题
算法训练 装箱问题 时间限制:1.0s 内存限制:256.0MB 问题描述 有一个箱子容量为V(正整数,0<=V<=20000),同时有n个物品(0<n<=30),每 ...
- java中输入3个数,从大到小的输出。。。。
总结:我暂时不能理解,C语言时讲过,java里就不理解了 package com.a; import java.sql.Date; import java.util.Scanner; //输入三个数, ...