字符串置换 -LintCode
来源:互联网 发布:珠宝设计软件手机 编辑:程序博客网 时间:2024/06/05 14:28
给定两个字符串,请设计一个方法来判定其中一个字符串是否为另一个字符串的置换。
置换的意思是,通过改变顺序可以使得两个字符串相等
样例:
“abc” 为 “cba” 的置换。
“aabc” 不是 “abcc” 的置换。
#ifndef C211_H#define C211_H#include<iostream>#include<string>#include<map>using namespace std;class Solution {public: /* * @param A: a string * @param B: a string * @return: a boolean */ bool Permutation(string &A, string &B) { // write your code here if (A.empty() || B.empty()) { if (A.empty() && B.empty()) return true; else return false; } if (A.size() != B.size()) return false; map<char, int> m; for (int i = 0; i < A.size(); ++i) m[A[i]]++; for (int j = 0; j < B.size(); ++j) m[B[j]]--; for (int k = 0; k < m.size(); ++k) { if (m[k] != 0) { return false; break; } } return true; }};#endif
阅读全文
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.字符串置换(词语变形 互为变形词)
- 字符串置换
- Android Oreo 可下载字体
- oracle vm virtualbox安装 ubuntu出现 x00000000内存错误
- Android CountDownTimer倒计时器
- 运行eclipse出现 no java virtual machine not found
- 总监级思考!TO B 和 TO C产品有哪些异同点?
- 字符串置换 -LintCode
- 直接插入排序
- lock锁和monitor.enter锁
- 不知道真的假的 的自适应
- 进程、、、
- Spring--(模拟HiberanteTemplate、HibernateCallBack实现)
- "const char *" 类型的实参与 "LPCTSTR" 类型的形参不兼容
- 写一个类似与CASE功能的状态切换函数
- FPGA与安防领域