lintcode--字符串置换
来源:互联网 发布:mac vi怎么保存退出 编辑:程序博客网 时间:2024/06/01 10:39
给定两个字符串,请设计一个方法来判定其中一个字符串是否为另一个字符串的置换。
置换的意思是,通过改变顺序可以使得两个字符串相等。
"abc"
为 "cba"
的置换。
"aabc"
不是 "abcc"
的置换。
public class Solution {
public boolean stringPermutation(String A, String B) {
// Write your code here
if(A==null && B==null)
return true;
if(A==null || B==null)
return false;
if(A.length() !=B.length())
return false;
int[] C = new int[256];
for(int i=0;i<A.length();i++){
char c1 = A.charAt(i);
char c2 = B.charAt(i);
C[c1]++;//C[a]++;
C[c2]--;//C[c]--;
}
for(int i=0;i<256;i++){
if(C[i]!=0)
return false;
}
return true;
}
}
- 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.字符串置换(词语变形 互为变形词)
- 字符串置换
- 函数重载
- ArrayList和LinkedList的区别
- Android Studio中配置及使用OpenCV示例(一)
- hdu6143-Killer Names
- 1013.Digital Roots
- lintcode--字符串置换
- 把字节数B转换为KB,MB,GB的方法
- hdu2086
- mysql 性能排查3板斧
- 写法
- Webview常用的方法
- python编程常用方法总结
- uname命令与uuname命令
- 利用外键关系实现多表关联更新