Mayonaize
Mayonaize
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
good night
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
again tysm
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
ill go over this tmrw
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
Thank you so mcuh for the help i really really really appreciate it
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
i needs go to sleep i got school in 5 hours
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
mannnnn
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
doesnt workkkk
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
i really hope this works cuz i gotta go sleep its 2:30 am
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
public Node<int> DuplicateListWithoutConsecutiveValueSequencesLongerThan2(Node<int> listHead)
{
var resultHead = new Node<int>(0, listHead);
var prevNode = resultHead;
var currentNode = listHead;

currentNode = currentNode.GetNext();
while (currentNode != null)
{
Node<int> nextNode = currentNode.GetNext();
int counter = 1;
while (nextNode != null && currentNode.GetValue() == nextNode.GetValue())
{
counter++;
nextNode = nextNode.GetNext();
}
if (counter >= 3){prevNode.SetNext(nextNode);}

else {prevNode = currentNode;}

currentNode = nextNode;

currentNode = currentNode.GetNext(); //If nodes get deleted it goes straight to the place after deletion, if not it goes the the place after checking the duplicates.
}
return listHead;
}
public Node<int> DuplicateListWithoutConsecutiveValueSequencesLongerThan2(Node<int> listHead)
{
var resultHead = new Node<int>(0, listHead);
var prevNode = resultHead;
var currentNode = listHead;

currentNode = currentNode.GetNext();
while (currentNode != null)
{
Node<int> nextNode = currentNode.GetNext();
int counter = 1;
while (nextNode != null && currentNode.GetValue() == nextNode.GetValue())
{
counter++;
nextNode = nextNode.GetNext();
}
if (counter >= 3){prevNode.SetNext(nextNode);}

else {prevNode = currentNode;}

currentNode = nextNode;

currentNode = currentNode.GetNext(); //If nodes get deleted it goes straight to the place after deletion, if not it goes the the place after checking the duplicates.
}
return listHead;
}
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
ok i think i might have got it
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
wait maybe not to next but to current?
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
but only if it doesnt?
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
if it doesnt i guess i need to change prev current?
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
and like
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
links next node and prev node
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
but what i did kinda like
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
maybe i have a mistake
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
ok so i think i got it
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
idk how to explainw ith words
271 replies
CC#
Created by Mayonaize on 10/29/2023 in #help
❔ Removing dupes in a linked list
and like use previous to link the thingies
271 replies