-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListNode.cs
More file actions
40 lines (36 loc) · 978 Bytes
/
Copy pathListNode.cs
File metadata and controls
40 lines (36 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace algorithms.LeetCode;
public class ListNode
{
public int val;
public ListNode? next;
public ListNode(int val = 0, ListNode? next = null)
{
this.val = val;
this.next = next;
}
public void Print()
{
Console.WriteLine($"val: {this.val}");
}
public void PrintAll()
{
var a = new ListNode(this.val, this.next);
do{
Console.Write($"val: {a.val}");
if(a.next is not null) Console.Write("\t");
a = a.next;
}while(a is not null);
Console.WriteLine();
}
public void PrintAll(int count)
{
var a = new ListNode(this.val, this.next);
do{
Console.Write($"val: {a.val}");
if(a.next is not null) Console.Write("\t");
a = a.next;
count--;
}while(a is not null && count > 0);
Console.WriteLine();
}
}