/*function ListNode(x){
this.val = x;
this.next = null;
}*/
function deleteDuplication(pHead)
{
// write code here
if(!pHead) {
return null;
}
let arr = [];
let tempRes = pHead;
let res = pHead;
while(tempRes) {
arr.push(tempRes.val);
tempRes = tempRes.next;
}
while(res.next) {
if(arr.indexOf(res.next.val) !== arr.lastIndexOf(res.next.val)) {
res.next = res.next.next;
} else {
res = res.next;
}
}
if(arr.indexOf(pHead.val) !== arr.lastIndexOf(pHead.val)) {
if(pHead.next) {
return pHead.next;
}
return null;
}
return pHead;
}
module.exports = {
deleteDuplication : deleteDuplication
};