mirror of
https://github.com/mudabbir-ahmad/Leet-Code-prog.git
synced 2026-10-08 02:30:21 +00:00
add merging_strings_alternatively implementation and update CMakeLists.txt
This commit is contained in:
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;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Created by bob on 02/05/2026.
|
||||
//
|
||||
|
||||
#ifndef LEET_CODE_PROG_MERGING_STRINGS_ALTERNATIVELY_H
|
||||
#define LEET_CODE_PROG_MERGING_STRINGS_ALTERNATIVELY_H
|
||||
|
||||
|
||||
class merging_strings_alternatively {
|
||||
};
|
||||
|
||||
|
||||
#endif //LEET_CODE_PROG_MERGING_STRINGS_ALTERNATIVELY_H
|
||||
Reference in new issue
Block a user