Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm> //сильно усложнил
- //Algorithm Manacher palindrome
- using namespace std;
- void IsPalindrome(string str) {
- vector<char>word;
- vector<char>reverse_word;
- for (const auto& s: str) {
- word.push_back(s);
- reverse_word.push_back(s);
- }
- reverse(reverse_word.begin(), reverse_word.end());
- if (word == reverse_word) {
- std::cout << 1 << endl;
- }
- else {
- std::cout << 0 << endl;
- }
- }
- int main() {
- IsPalindrome("V");
- IsPalindrome("ara"s);
- IsPalindrome("deer"s);
- IsPalindrome(""s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement