LintCode(easy)比较字符串(正确版)
来源:互联网 发布:淘宝嘉悦海外专营店 编辑:程序博客网 时间:2024/05/01 23:43
class Solution {public: /** * @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 */ bool compareStrings(string A, string B) { bool w; string a(26, '0'), b(26, '0'); int m, n; if (A.size() < B.size()) w=false; else{ //如果B为空 if(B=="") w=true; else{ //循环A for (int i = 0; i < A.size(); i++){ m = A[i] - 65; a[m] ++; } //循环B for (int i = 0; i < B.size(); i++){ n = B[i] - 65; b[n] ++; } for (int i = 0; i < B.size(); i++){ if (a[i]>b[i])a[i] = b[i]; //if (b[i] == '0') b[i] = a[i]; }//cout << a << endl << b<<endl; //比较 if (a >= b){ w = true; //return w; } else w = false; // cout << w; }} return w; }};
0 0
- LintCode(easy)比较字符串(正确版)
- LintCode(easy)字符串查找
- LintCode(easy)翻转字符串
- LintCode(easy)字符串查找(bug集)
- LintCode(容易)55.比较字符串
- Lintcode—(3)比较字符串
- Lintcode(2)-比较字符串
- LintCode比较字符串
- Lintcode 比较字符串
- lintcode-比较字符串-55
- LintCode 比较字符串
- Lintcode 比较字符串
- LintCode-比较字符串
- lintcode刷题--比较字符串
- LintCode 比较字符串
- Lintcode-比较字符串
- lintcode ----比较字符串
- LintCode之比较字符串
- Ant-build.xml配置说明
- JQuery效果
- C# 读取EXCEL文件的三种经典方法
- 用WeX5做一个二维码名片应用!有源码!
- opendir, readdir
- LintCode(easy)比较字符串(正确版)
- 从Script到Code Blocks、Code Behind到MVC、MVP、MVVM
- 【FJ省队训练&&NOIP夏令营】酱油&&滚粗记
- linux socket 编程(二)
- JQuery选择器
- P1001 蓝桥杯算法提高-用字符串处理大数乘法
- mysql多字段排序问题
- Android的Handler机制原理
- 深入理解-字符编码ASCII,GB2312,GBK,Unicode,UTF-8