We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd57c90 commit a96c4d5Copy full SHA for a96c4d5
1 file changed
data_structures/linked_list/xor_linked_list.py
@@ -17,17 +17,18 @@
17
18
19
class Node:
20
- def __init__(self, value: int):
+ def __init__(self, value: int) -> None:
21
self.value = value
22
self.both: int = 0 # XOR of prev and next node ids
23
24
25
class XORLinkedList:
26
- def __init__(self):
+ def __init__(self) -> None:
27
self.head: Optional[Node] = None
28
self.tail: Optional[Node] = None
29
self._nodes = {} # id → node map to simulate pointer references
30
31
+
32
def _xor(self, a: Optional[Node], b: Optional[Node]) -> int:
33
return (id(a) if a else 0) ^ (id(b) if b else 0)
34
0 commit comments