https://leetcode-cn.com/problems/convert-binary-number-in-a-linked-list-to-integer
Swift
func getDecimalValue(_ head: ListNode?) -> Int {
var current: ListNode? = nil
current = head
var decimals = [Int]()
while current != nil {
decimals.append(current!.val)
current = current?.next
}
var output = 0
for index in 0..<decimals.count {
let y = Double(decimals.count-1-index)
let x = Double(2)
output = output + decimals[index] * Int(pow(x, y))
}
return output
}