You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
785 B
38 lines
785 B
package main
|
|
|
|
import "fmt"
|
|
|
|
/**
|
|
给你两个非空 的链表,表示两个非负的整数。
|
|
它们每位数字都是按照逆序的方式存储的,并且每个节点只能存储一位数字。
|
|
请你将两个数相加,并以相同形式返回一个表示和的链表。 你可以假设除了数字 0 之外,这两个数都不会以 0开头。
|
|
*/
|
|
|
|
/**
|
|
* Definition for singly-linked list.
|
|
* type ListNode struct {
|
|
* Val int
|
|
* Next *ListNode
|
|
* }
|
|
*/
|
|
type ListNode struct {
|
|
Val int
|
|
Next *ListNode
|
|
}
|
|
|
|
func main() {
|
|
l1 := new(ListNode)
|
|
l2 := new(ListNode)
|
|
l1.Val = 0
|
|
l2.Val = 2
|
|
fmt.Println(addTwoNumbers(l1, l2))
|
|
}
|
|
|
|
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
|
|
|
|
fmt.Printf("l1Val: %v\n", l1.Val)
|
|
fmt.Printf("l2Val: %v\n", l2.Val)
|
|
|
|
return nil
|
|
}
|