leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1071.cpp (201B)


      1 class Solution {
      2   public:
      3     string gcdOfStrings(string str1, string str2) {
      4         if (str1 + str2 != str2 + str1) return "";
      5         return str1.substr(0, gcd(str1.size(), str2.size()));
      6     }
      7 };