commit 3ee55c0e521bc706d1d73d229c343f79e2936bd3
parent 9e61935bb3d8aac3946e9113463b124850721305
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 8 Oct 2024 21:44:48 +0200
1 Random Problem
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/Problems/1754.cpp b/Problems/1754.cpp
@@ -0,0 +1,18 @@
+class Solution {
+ public:
+ string largestMerge(const string &word1, const string &word2) const {
+ const int n = size(word1), m = size(word2);
+ int i = 0, j = 0;
+ string res;
+
+ while (i < n && j < m) {
+ if (word1[i] == word2[j]) {
+ res += word1.substr(i) > word2.substr(j) ? word1[i++] : word2[j++];
+ } else {
+ res += word1[i] > word2[j] ? word1[i++] : word2[j++];
+ }
+ }
+
+ return res + word1.substr(i) + word2.substr(j);
+ }
+};
diff --git a/README.md b/README.md
@@ -991,6 +991,7 @@ for solving problems.
| 1750 | Medium | [Minimum Length of String After Deleting Similar Ends](Problems/1750.cpp) |
| 1751 | Hard | [Maximum Number of Events That Can Be Attended II](Problems/1751.cpp) |
| 1753 | Medium | [Maximum Score From Removing Stones](Problems/1753.cpp) |
+| 1754 | Medium | [Largest Merge Of Two Strings](Problems/1754.cpp) |
| 1757 | Easy | [Recyclable and Low Fat Products](Problems/1757.cpp) |
| 1758 | Easy | [Minimum Changes To Make Alternating Binary String](Problems/1758.cpp) |
| 1759 | Medium | [Count Number of Homogenous Substrings](Problems/1759.cpp) |