Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
remove dups
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using COLG = System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Node { public int data; public Node next; public Node (int value) { data = value; next = null; } } public class ListManager { public Node RemoveDuplicates (ref Node head) { COLG.List<Node> seen = new COLG.List<Node>(); Node previous = head; Node current = head.next; seen.Add(previous); while (current != null) { if (seen.Exists(x => x.data == current.data)) { previous.next = current.next; } else { seen.Add(current); previous = current; } current = current.next; } return head; } public void Traverse (ref Node head) { while (head != null) { Console.WriteLine(head.data); head = head.next; } } } public class Program { public static void Main(string[] args) { //create nodes Node first = new Node(5); Node second = new Node(9); Node third = new Node(3); Node fourth = new Node(5); Node fifth = new Node(3); //link nodes into a linked list first.next = second; second.next = third; third.next = fourth; fourth.next = fifth; ListManager manager = new ListManager(); Node head = manager.RemoveDuplicates(ref first); manager.Traverse(ref head); } } }
run
|
edit
|
history
|
help
0
StackOverflow Generic
BreakNum
gfhfgsdfsfdsdghgfddfg
Amortizacion de prestamos con el metodo Frances
svsvsvsvsv
First code
6.1 Parallelism: race conditions
test save
Truncate String by Byte
a