// defining a linked list
let LL = {data: 1, next: {data: 2, next: {data: 3, next: {data: 1, next: {data: 2, next: {data: 5, next: {data:1, next: null}}}}}}};
let HEAD = LL;
while(HEAD != null) {
let HEAD2 = HEAD;
while( HEAD2.next != null) {
if(HEAD.data == HEAD2.next.data) {
HEAD2.next = HEAD2.next.next;
} else {
HEAD2 = HEAD2.next;
}
}
HEAD = HEAD.next;
}
console.log(LL);
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)