Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Remove duplicates in a linked list
//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 System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class LinkedList { public Node head; public Node current; public int count; public LinkedList() { head = new Node(12); current = head; } } public class Node { public int data; public Node next; public Node(int n) { this.data = n; } } public class Program { public static void Main(string[] args) { LinkedList list = new LinkedList(); list.head.next = new Node(10); list.head.next.next = new Node(15); list.head.next.next.next = new Node(16); list.head.next.next.next.next = new Node(10); printNodes(list.head); removeDuplicates(list.head); printNodes(list.head); } public static void printNodes(Node n) { while(n!=null) { Console.WriteLine(n.data); n = n.next; } } public static void removeDuplicates(Node n) { Node current = n; Node runner = current; if(n == null) return; while(current!=null) { while(runner.next!=null) { if(current.data == runner.data) { current.next = runner.next.next; } runner = runner.next; } current = current.next; } } } }
run
|
edit
|
history
|
help
0
Blooket
Live tv 2021
My name
Swap adjacent Elements
8
Linked List with basic functions.
Customer bill information
to get distinct of the given array with each items occurrence count._1
Insertion Sort
NumsToVars