阿里云 超级码力在线编程大赛初赛 第4场 题目3. from start to end

文章目录

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阿明),一起加油、一起学习进步!
Michael阿明

猜你喜欢

转载自blog.csdn.net/qq_21201267/article/details/108430839
今日推荐