LintCode-比较字符串
来源:互联网 发布:知天下资源站封了 编辑:程序博客网 时间:2024/05/10 12:36
比较字符串
比较两个字符串A和B,确定A中是否包含B中所有的字符。字符串A和B中的字符都是 大写字母
样例
给出 A = “ABCD” B = “ACD”,返回 true
给出 A = “ABCD” B = “AABC”, 返回 false
注意
在 A 中出现的 B 字符串里的字符不需要连续或者有序。
public class Solution { /** * @param A : A string includes Upper Case letters * @param B : A string includes Upper Case letter * @return : if string A contains all of the characters in B return true else return false */ public boolean compareStrings(String A, String B) { int [] re = new int [26]; for(int i = 0; i < A.length(); i++){ re[(int)(A.charAt(i)-'A')]++; } for(int i = 0; i<B.length(); i++){ if(re[(int)(B.charAt(i)-'A')]-- == 0){ return false; } } return true; }}
0 0
- Lintcode(2)-比较字符串
- LintCode比较字符串
- Lintcode 比较字符串
- lintcode-比较字符串-55
- LintCode 比较字符串
- Lintcode 比较字符串
- LintCode-比较字符串
- lintcode刷题--比较字符串
- LintCode 比较字符串
- Lintcode-比较字符串
- lintcode ----比较字符串
- LintCode之比较字符串
- lintCode 55:比较字符串
- LintCode : 比较字符串
- Lintcode 比较字符串
- LintCode 54 比较字符串
- LintCode-比较字符串
- lintcode -- 比较字符串
- POJ1548-Robots Dilworth 定理
- 通过Demo了解AlertDialog的构造原理
- djvulibre使用简单说明
- 杀死进程、退出应用程序时提示、自定义apk安装、反编译
- Week1-1Human language and animal communication systems
- LintCode-比较字符串
- bzoj2751【haoi2012】容易题(easy)
- nginx配置ajp
- Doxygen for C++使用说明——注释代码一
- test
- OC中的类簇
- 程序员眼中的单词
- linux学习网站
- bzoj1858【scoi2010】序列操作