diff options
Diffstat (limited to 'other/remove_palindromic_subsequence.cpp')
-rw-r--r-- | other/remove_palindromic_subsequence.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/other/remove_palindromic_subsequence.cpp b/other/remove_palindromic_subsequence.cpp new file mode 100644 index 0000000..cbf7182 --- /dev/null +++ b/other/remove_palindromic_subsequence.cpp @@ -0,0 +1,19 @@ +#include "leetcode.h" + +class Solution { +public: + int removePalindromeSub(string s) { + if (s.size() == 0) + return 0; + for (int i = 0, j = s.size() - 1; i < j; i++, j--) + if (s[i] != s[j]) + return 2; + return 1; + } +}; + +int main() { + string s = "ababa"; + Solution obj; + cout << obj.removePalindromeSub(s); +} |