在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list.
Example 1:
Input: head = [0] Input: head = [1] Input: head = [1,0,0,1,0,0,1,1,1,0,0,0,0,0,0] Input: head = [0,0] Constraints: The Linked List is not empty. 给你一个单链表的引用结点 head。链表中每个结点的值不是 0 就是 1。已知此链表是一个整数数字的二进制表示形式。 请你返回该链表所表示数字的 十进制值 。
示例 1:
输入:head = [1,0,1] 输入:head = [0] 输入:head = [1] 输入:head = [1,0,0,1,0,0,1,1,1,0,0,0,0,0,0] 输入:head = [0,0] 提示: 链表不为空。 |
请发表评论