commit f09f44fa95e8eebd4941c50c9f242f4f33f3a164
parent ee9a007f588e4b0b04254508c5f215e8893193c4
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 14 May 2024 16:35:23 +0200
1 Random Problem
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Problems/1328.cpp b/Problems/1328.cpp
@@ -0,0 +1,16 @@
+class Solution {
+ public:
+ string breakPalindrome(string palindrome) const {
+ const int n = size(palindrome);
+ if (n == 1) return "";
+
+ for (int i = 0; i < n / 2; i++) {
+ if (palindrome[i] == 'a') continue;
+ palindrome[i] = 'a';
+ return palindrome;
+ }
+
+ palindrome[n - 1] = 'b';
+ return palindrome;
+ }
+};
diff --git a/README.md b/README.md
@@ -737,6 +737,7 @@ for solving problems.
| 1325 | Medium | [Delete Leaves With a Given Value](Problems/1325.cpp) |
| 1326 | Hard | [Minimum Number of Taps to Open to Water a Garden](Problems/1326.cpp) |
| 1327 | Easy | [List the Products Ordered in a Period](Problems/1327.cpp) |
+| 1328 | Medium | [Break a Palindrome](Problems/1328.cpp) |
| 1329 | Medium | [Sort the Matrix Diagonally](Problems/1329.cpp) |
| 1333 | Medium | [Filter Restaurants by Vegan-Friendly, Price and Distance](Problems/1333.cpp) |
| 1334 | Medium | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](Problems/1334.cpp) |