leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE |

1328.cpp (387B)


1 class Solution { 2 public: 3 string breakPalindrome(string palindrome) const { 4 const int n = size(palindrome); 5 if (n == 1) return ""; 6 7 for (int i = 0; i < n / 2; i++) { 8 if (palindrome[i] == 'a') continue; 9 palindrome[i] = 'a'; 10 return palindrome; 11 } 12 13 palindrome[n - 1] = 'b'; 14 return palindrome; 15 } 16 };