leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 496ccdcd72dbb90958ff2fffbbcb9c013fb8e36a |
parent | 1ef59548b1c0221014ad9d25f8a23c594ee2fdba |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Tue, 18 Apr 2023 08:17:30 +0200 |
Daily Problem
Diffstat:A | Problems/1768.cpp | | | +++++++++++++++++ |
M | README.md | | | + |
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Problems/1768.cpp b/Problems/1768.cpp
@@ -0,0 +1,17 @@
class Solution {
public:
string mergeAlternately(string word1, string word2) {
int i = 0, j = 0;
string res = "";
while (i < word1.size() && j < word2.size()) {
res += word1[i++];
res += word2[j++];
}
while (i < word1.size()) res += word1[i++];
while (j < word2.size()) res += word2[j++];
return res;
}
};
diff --git a/README.md b/README.md
@@ -460,6 +460,7 @@ for solving problems.
| 1704 | Easy | [Determine if String Halves Are Alike](Problems/1704.cpp) |
| 1706 | Medium | [Where Will the Ball Fall](Problems/1706.cpp) |
| 1722 | Medium | [Minimize Hamming Distance After Swap Operations](Problems/1722.cpp) |
| 1768 | Easy | [Merge Strings Alternately](Problems/1768.cpp) |
| 1786 | Medium | [Number of Restricted Paths From First to Last Node](Problems/1786.cpp) |
| 1791 | Easy | [Find Center of Star Graph](Problems/1791.cpp) |
| 1823 | Medium | [Find the Winner of the Circular Game](Problems/1823.cpp) |