From b29cd3775d403e2f752ee27b3756a56ff3a170f4 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Fri, 8 May 2026 18:57:31 +0100 Subject: [PATCH] sol --- Easy/Common_Divisor_Of_Two_Strings/Solution.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Easy/Common_Divisor_Of_Two_Strings/Solution.cpp b/Easy/Common_Divisor_Of_Two_Strings/Solution.cpp index a3d8fee..f838bfb 100644 --- a/Easy/Common_Divisor_Of_Two_Strings/Solution.cpp +++ b/Easy/Common_Divisor_Of_Two_Strings/Solution.cpp @@ -5,4 +5,8 @@ public: str1.substr(0, gcd(size(str1),size(str2))) // whats being returned = SUBSTRING starting from 0 to the gcd ( COMMON DIVISOR FOR ) the size of str1 and str2 : ""; // else return nothing } -}; \ No newline at end of file +}; + +// if str1 = BoomBoom and str2 = Boom +// Then str1 + str2 = BoomBoomBoom and str2 + str1 = BoomBoomBoom (they're the same) so we return the substring of str1 starting at 0 to the gcd of the size of str1 and str2 +// size of str1 = 8 and size of str2 = 4 so the gcd of 8 and 4 is 4 so we return the substring of str1 starting at 0 to 4 which is Boom