add merging_strings_alternatively implementation and update CMakeLists.txt

This commit is contained in:
bobbert committed 2026-05-02 15:36:17 +01:00
1 parent c6f7c8cd5b
commit 72f331a771
4 files changed
+279 -1

No files matched your search

@@ -0,0 +1,28 @@
//
// Created by bob on 02/05/2026.
//
#include "merging_strings_alternatively.h"
class merging_strings_alternatively {
public:
string mergeAlternately(string word1, string word2) {
int i = 0;
string out = "";
int l1 = word1.length();
int l2 = word2.length();
while (i < l1 || i < l2)
{
if (i < l1){
out += word1[i];
}
if (i < l2){
out += word2[i];
}
i++;
}
return out;
}
};