package leetcode import ( "github.com/halfrost/LeetCode-Go/structures" ) // ListNode define type ListNode = structures.ListNode /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func getDecimalValue(head *ListNode) int { sum := 0 for head != nil { sum = sum*2 + head.Val head = head.Next } return sum }