1. 题目
样例1:
输入:
"abcd"
"bcda"
输出:
true
样例2:
输入:
"abcd"
"abdc"
输出:
false
来源:https://tianchi.aliyun.com/oj/15193368247341694/33967147358294629
2. 解题
- 长度要一样
- s1+s1 中能找到 s2 才行
class Solution {
public:
/**
* @param s1: the string 1
* @param s2: the string 2
* @return: judge can s1 change to s2
*/
bool judge(string &s1, string &s2) {
// write your code here
if(s1.size() != s2.size())
return false;
return (s1+s1).find(s2) != string::npos;
}
};
我的CSDN博客地址 https://michael.blog.csdn.net/
长按或扫码关注我的公众号(Michael阿明),一起加油、一起学习进步!