Add Go codes to docs, including

the chapter of stack and queue, the chapter of tree.
This commit is contained in:
Yudong Jin
2022-12-03 20:25:24 +08:00
parent 1d9a076cdd
commit ebf9024136
41 changed files with 898 additions and 486 deletions

View File

@@ -4,12 +4,6 @@
package pkg
import (
"fmt"
"strconv"
"strings"
)
// ListNode Definition for a singly-linked list node
type ListNode struct {
Next *ListNode
@@ -43,17 +37,3 @@ func GetListNode(node *ListNode, val int) *ListNode {
}
return node
}
// PrintLinkedList Print a linked list
func PrintLinkedList(node *ListNode) {
if node == nil {
return
}
var builder strings.Builder
for node.Next != nil {
builder.WriteString(strconv.Itoa(node.Val) + " -> ")
node = node.Next
}
builder.WriteString(strconv.Itoa(node.Val))
fmt.Println(builder.String())
}