leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1328.cpp (387B)
0 class Solution {
1 public:
2 string breakPalindrome(string palindrome) const {
3 const int n = size(palindrome);
4 if (n == 1) return "";
6 for (int i = 0; i < n / 2; i++) {
7 if (palindrome[i] == 'a') continue;
8 palindrome[i] = 'a';
9 return palindrome;
10 }
12 palindrome[n - 1] = 'b';
13 return palindrome;
14 }
15 };