Browse Source

Node to NodeAddL

content-update
OGordoo 5 years ago
parent
commit
5f44588a6f
  1. 14
      subjects/addlinkednumbers.en.md
  2. 8
      subjects/changeorder.en.md
  3. 10
      subjects/reverse.en.md
  4. 8
      subjects/sortll.en.md

14
subjects/addlinkednumbers.en.md

@ -13,7 +13,7 @@ This means that:
### Instructions
You have two numbers represented by a linked list, where each node contains a single digit.
You have two numbers represented by a linked list, where each NodeAddL contains a single digit.
The digits are stored in reverse order, such that the 1’s digit is at the head of the list.
Write a function that adds the two numbers and returns the sum as a linked list
@ -22,12 +22,12 @@ Write a function that adds the two numbers and returns the sum as a linked list
```go
package main
type Node struct {
Next *Node
type NodeAddL struct {
Next *NodeAddL
Num int
}
func AddLinkedNumbers(num1, num1 *Node) *Node {
func AddLinkedNumbers(num1, num1 *NodeAddL) *NodeAddL {
}
```
@ -43,19 +43,19 @@ import (
"fmt"
)
func pushFront(node *Node, num int) *Node {
func pushFront(node *NodeAddL, num int) *NodeAddL {
// ...
// Write yourself
}
func main() {
// 3 -> 1 -> 5
num1 := &Node{Num:5}
num1 := &NodeAddL{Num:5}
num1 = pushFront(num1, 1)
num1 = pushFront(num1, 3)
// 5 -> 9 -> 2
num2 := &Node{Num:2}
num2 := &NodeAddL{Num:2}
num2 = pushFront(num2, 9)
num2 = pushFront(num2, 5)

8
subjects/changeorder.en.md

@ -23,12 +23,12 @@ You have to return pointer/reference to the beginning of new list
```go
package main
type Node struct {
Next *Node
type NodeAddL struct {
Next *NodeAddL
Num int
}
func Changeorder(node *Node) *Node {
func Changeorder(node *NodeAddL) *NodeAddL {
}
```
@ -47,7 +47,7 @@ import (
// I implemented pushBack for this
func main() {
num1 := &Node{Num: 1}
num1 := &NodeAddL{Num: 1}
num1 = pushBack(num1, 2)
num1 = pushBack(num1, 3)
num1 = pushBack(num1, 4)

10
subjects/reverse.en.md

@ -21,12 +21,12 @@ Write a function that reverses the list and returns pointer/reference to new lin
```go
package main
type Node struct {
Next *Node
type NodeAddL struct {
Next *NodeAddL
Num int
}
func Reverse(node *Node) *Node {
func Reverse(node *NodeAddL) *NodeAddL {
}
```
@ -42,12 +42,12 @@ import (
"fmt"
)
func pushBack(n *Node, num int) *Node{
func pushBack(n *NodeAddL, num int) *NodeAddL{
}
func main() {
num1 := &piscine.Node{Num: 1}
num1 := &piscine.NodeAddL{Num: 1}
num1 = pushBack(num1, 3)
num1 = pushBack(num1, 2)
num1 = pushBack(num1, 4)

8
subjects/sortll.en.md

@ -21,12 +21,12 @@ Write a function that sorts the list in descending order and return pointer/refe
```go
package piscine
type Node struct {
Next *Node
type NodeAddL struct {
Next *NodeAddL
Num int
}
func Sortll(node *Node) *Node {
func Sortll(node *NodeAddL) *NodeAddL {
}
```
@ -45,7 +45,7 @@ import (
// I implemented pushBack for this
func main() {
num1 := &piscine.Node{Num: 5}
num1 := &piscine.NodeAddL{Num: 5}
num1 = pushBack(num1, 1)
num1 = pushBack(num1, 3)
num1 = pushBack(num1, 1)

Loading…
Cancel
Save