LintCode-字符串置换
来源:互联网 发布:天龙八部穿刺伤害数据 编辑:程序博客网 时间:2024/06/05 07:01
给定两个字符串,请设计一个方法来判定其中一个字符串是否为另一个字符串的置换。
置换的意思是,通过改变顺序可以使得两个字符串相等。
样例
"abc" 为 "cba" 的置换。"aabc" 不是 "abcc" 的置换。
思路
我们可以把字符串换成字符数组,排列,在一 一对比
代码
public class Solution { /* * @param A: a string * @param B: a string * @return: a boolean */ public boolean Permutation(String A, String B) { // write your code here if(A.length()!=B.length()) return false; char [] a=A.toCharArray(); char [] b=B.toCharArray(); Arrays.sort(a); Arrays.sort(b); for(int i=0;i<A.length();i++) { if(a[i]!=b[i]) return false; } return true; }};
阅读全文
0 0
- LintCode 字符串置换 JAVA
- LintCode之字符串置换
- LintCode-字符串置换
- lintcode--字符串置换
- LintCode:字符串置换211
- LintCode 字符串置换
- 字符串置换-lintcode-c++
- LintCode 字符串置换 python
- 字符串置换 -LintCode
- Lintcode字符串置换
- lintcode 211 字符串置换
- Lintcode 211 :字符串置换
- [LintCode] 字符串置换 String Permutation
- LintCode-[容易] 211. 字符串置换
- 字符串置换 LintCode by python
- LintCode-[容易] 211. 字符串置换
- [LintCode]211.字符串置换(词语变形 互为变形词)
- 字符串置换
- WebRTC中丢包重传机制的实现
- MySQL innodb waiting for table level lock 问题解决
- POJ1363
- Golang Protobuf
- Keras模块简述
- LintCode-字符串置换
- 常见的出现login incorrect有下面几个原因: 1)大小写键盘问题,Ubuntu不认小键盘,所以一定要关掉NumLock,使用字母键盘上面的数字按键进行输入。
- c# 遍历字典
- iOS中socket通信---基于CocoaAsyncSocket实现
- ubuntu安装mysql 时未提示输入密码
- define 与 const 的区别(学习_转录)
- Intellij IDEA 快捷键整理
- 松果
- file_put_contents()写入数组