mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-17 14:10:57 +00:00
Add ru version (#1865)
* Add Russian docs site baseline * Add Russian localized codebase * Polish Russian code wording * Update ru code translation. * Update code translation and chapter covers. * Fix pythontutor extraction. * Add README and landing page. * placeholder of profiles * Use figures of English version * Remove chapter paperbook
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// File: list_node.go
|
||||
// Created Time: 2022-11-25
|
||||
// Author: Reanon (793584285@qq.com)
|
||||
|
||||
package pkg
|
||||
|
||||
// ListNode: узел связного списка
|
||||
type ListNode struct {
|
||||
Next *ListNode
|
||||
Val int
|
||||
}
|
||||
|
||||
// NewListNode: конструктор узла связного списка
|
||||
func NewListNode(v int) *ListNode {
|
||||
return &ListNode{
|
||||
Next: nil,
|
||||
Val: v,
|
||||
}
|
||||
}
|
||||
|
||||
// ArrayToLinkedList десериализует массив в связный список
|
||||
func ArrayToLinkedList(arr []int) *ListNode {
|
||||
// dummy header of linked list
|
||||
dummy := NewListNode(0)
|
||||
node := dummy
|
||||
for _, val := range arr {
|
||||
node.Next = NewListNode(val)
|
||||
node = node.Next
|
||||
}
|
||||
return dummy.Next
|
||||
}
|
||||
Reference in New Issue
Block a user