0
点赞
收藏
分享

微信扫一扫

【Leetcode_easy】1071. Greatest Common Divisor of Strings

自信的姐姐 2022-07-12 阅读 52

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​​;

举报

相关推荐

0 条评论