Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- /****************************************************************
- Following is the class structure of the LinkedListNode class:
- template <typename T>
- class LinkedListNode
- {
- public:
- T data;
- LinkedListNode<T> *next;
- LinkedListNode(T data)
- {
- this->data = data;
- this->next = NULL;
- }
- };
- *****************************************************************/
- bool isPalindrome(LinkedListNode<int> *head) {
- LinkedListNode<int>* tmp = head;
- vector<int> v;
- while(tmp){
- v.push_back(tmp->data);
- tmp=tmp->next;
- }
- vector<int> w=v;
- reverse(w.begin(),w.end());
- return v == w;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement