Skip to content

Commit eed9691

Browse files
committed
Jul 14
1 parent d2d1581 commit eed9691

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Definition for singly-linked list.
2+
class ListNode:
3+
def __init__(self, val=0, next=None):
4+
self.val = val
5+
self.next = next
6+
7+
8+
class Solution:
9+
def getDecimalValue(self, head: ListNode) -> int:
10+
binary = 0
11+
while head is not None:
12+
binary *= 2
13+
binary += head.val
14+
head = head.next
15+
return binary
16+
17+
18+
def main():
19+
head = ListNode(1, ListNode(0, ListNode(1)))
20+
assert Solution().getDecimalValue(head) == 5
21+
22+
head = ListNode(0)
23+
assert Solution().getDecimalValue(head) == 0
24+
25+
26+
if __name__ == '__main__':
27+
main()

2025-07-July-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| July 11 | [2402. Meeting Rooms III](https://leetcode.com/problems/meeting-rooms-iii/) | Hard | Unsolved |
1818
| July 12 | [1900. The Earliest and Latest Rounds Where Players Compete](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete/) | Hard | Unsolved |
1919
| July 13 | [2410. Maximum Matching of Players With Trainers](https://leetcode.com/problems/maximum-matching-of-players-with-trainers/) | Medium | Solved |
20-
| July 14 | []() | | |
20+
| July 14 | [1290. Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/) | Easy | Solved |
2121
| July 15 | []() | | |
2222
| July 16 | []() | | |
2323
| July 17 | []() | | |
@@ -40,6 +40,6 @@
4040
## Summary
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
43-
| Easy | 3 | 3 | 0 |
43+
| Easy | 4 | 4 | 0 |
4444
| Medium | 5 | 5 | 0 |
4545
| Hard | 5 | 1 | 4 |

0 commit comments

Comments
 (0)