cc150 1.2 Check Permutation(排列)
来源:互联网 发布:中国依赖进口数据 编辑:程序博客网 时间:2024/06/06 18:19
1.2 Check Permutation(排列): Given 2 strings, write a method to decide if one is a permutation of the other
待确认问题:
1 是否大小写敏感(case sensitive)?
2 空格是否可以忽略?
思路:
1 排序
2 判断是否相等
C#代码:O(NLOGN)
public static bool Permutation(string str1,string str2) { if (str1 == string.Empty && str2 == string.Empty) return true; if (str1 == null || str2 == null) return false; char[] str1Arr = str1.Trim().ToCharArray(); char[] str2Arr = str2.Trim().ToCharArray(); Array.Sort(str1Arr); Array.Sort(str2Arr); return str1Arr.Equals(str2Arr); }
0 0
- cc150 1.2 Check Permutation(排列)
- 1.2 Check Permutation
- [cc150] 1.2
- 排列(Permutation)
- Array Q3 check permutation
- CC150
- 字符全排列Permutation
- 下一个排列(Next Permutation)
- Next Permutation 下一个排列
- [LeetCode]Permutation I排列
- 【排列】Permutation Sequence
- Permutation Sequence 生产排列
- 排列(permutation)
- 排列(permutation)
- 排列问题(permutation)
- Permutation Recovery(排列恢复)
- 全排列permutation
- Next Permutation 下一个排列
- 网站相关(协议,RESTful)
- JSP动作标签
- Linux系统下安装Vmware(虚拟机)图文教程步骤详细介绍
- 计算机基础的总结
- bin.sh not found
- cc150 1.2 Check Permutation(排列)
- 怎么开发微信公众号
- 实现mysql与sqlite数据互导
- 70. Climbing Stairs
- PHP背景水印图片生成代码
- Java 环境变量配置
- Maven丢失jdk.tools.jar
- plqsl中游标的出入控制
- 除法的用法,在变量后面加个 .