Created
January 28, 2019 15:58
-
-
Save armandocerna/31d6743e80998d1bd60f46367fca42d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sort" | |
) | |
type ListNode struct { | |
Val int | |
Next *ListNode | |
} | |
func main() { | |
l1 := &ListNode{Val:2, Next:&ListNode{Val:4, Next:&ListNode{Val:3}}} | |
l2 := &ListNode{Val:5, Next:&ListNode{Val:6, Next:&ListNode{Val:4}}} | |
_ = addTwoNumbers(l1, l2) | |
} | |
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode { | |
var num []int | |
fmt.Println(breakDown(l1, num)) | |
fmt.Println(breakDown(l2, num)) | |
return l1 | |
} | |
func breakDown(ln *ListNode, num []int) int { | |
if ln.Next != nil { | |
num = append(num, ln.Val) | |
breakDown(ln.Next, num) | |
} | |
sort.Reverse(num) | |
return n | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment