Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linked list problem with remove
//Linked list problem //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { // main public static void Main(string[] args) { //Your code goes here //Console.WriteLine("Hello, world!"); LinkedList myList = new LinkedList(); myList.AddHead(null); Console.WriteLine(myList.Length().ToString()); } // ListNode class - contains the data, and the next pointer public class ListNode { public object Data {get;set;} public ListNode Next {get;set;} } // The LinkedList class public class LinkedList { // The head of the list public ListNode Head {get;set;} // The LinkedList constructor public LinkedList() { } // Add a node to the head of the list with // the data public bool AddHead(object data) { return false; } /// <summary> /// Remove the node corresponding to the number passed in /// ** zero based index ** /// </summary> /// <param name="nodeNumber"></param> /// <returns></returns> public bool RemoveNode(int nodeNumber) { bool removed = false; return removed; } // Return the length of the list public int Length() { int length = 0; ListNode thisNode = Head; if(thisNode != null) { while(thisNode.Next != null) { length++; thisNode = thisNode.Next; } } return length; } } } }
run
|
edit
|
history
|
help
0
Does string contain only digits
xyz
xpath select element code
learning1
Lazy exception caching
FindSmallest
reverseandcheck
bitcount algo
Using Yield Return to mass copy a Class instance
Classes