【Leetcode_easy】1071. Greatest Common Divisor of Strings

problem

1071. Greatest Common Divisor of Strings

solution

class Solution {
public:
    string gcdOfStrings(string str1, string str2) {
        return (str1+str2==str2+str1) ? 
            (str1.substr(0, gcd(str1.size(), str2.size()))) : "";
    }
};

 

参考

1. Leetcode_easy_1071. Greatest Common Divisor of Strings;

posted on 2019-08-29 18:01  鹅要长大  阅读(106)  评论(0编辑  收藏  举报

导航