blob: ee2b1e4d79d9e7527fe85dda0d25e889579893e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include"../Seminar04/linked-list-utils.h"
bool isLinkedListPermRec(const LinkedListNode<int>*& begin, const LinkedListNode<int>* end) {
if(end == nullptr)
return true;
bool res = isLinkedListPermRec(begin, end->next) && (begin->data == end->data);
begin = begin->next;
return res;
}
template<class T>
bool isLinkedListPerm(const LinkedListNode<T>* ll) {
if(ll == nullptr)
return true;
const LinkedListNode<int>* begin = ll;
const LinkedListNode<int>* end = ll;
return isLinkedListPermRec(begin, end);
}
int main() {
LinkedListNode<int>* ll = new LinkedListNode(0, new LinkedListNode(1, new LinkedListNode(1)));
std::cout << isLinkedListPerm(ll);
}
|