We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 65f9fd0 commit 3ea60baCopy full SHA for 3ea60ba
DSA/LinkedList/main.go
@@ -0,0 +1,37 @@
1
+package main
2
+
3
+import "fmt"
4
5
+type Node struct {
6
+ data int
7
+ next *Node
8
+}
9
+type LinkedList struct {
10
+ head *Node
11
12
13
+func (l *LinkedList) Insert(value int) {
14
+ var newNode = new(Node)
15
+ newNode.data = value
16
+ newNode.next = l.head
17
+ l.head = newNode
18
19
+func (l *LinkedList) Print() {
20
+ var temp = l.head
21
+ for temp != nil {
22
+ fmt.Println(temp.data)
23
+ temp = temp.next
24
+ }
25
26
+ fmt.Println()
27
28
+func main() {
29
+ var l = new(LinkedList)
30
+ l.Insert(1)
31
+ l.Insert(2)
32
+ l.Insert(3)
33
+ l.Insert(4)
34
+ l.Insert(5)
35
36
+ l.Print()
37
0 commit comments