Skip to content

Commit aaaf447

Browse files
committed
Fix: format docstring line length
1 parent 49b6423 commit aaaf447

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
def single_number(nums: list[int]) -> int:
22
"""
3-
Find the element that appears only once in a list where every other element appears twice.
3+
Find the element that appears only once in a list
4+
where every other element appears twice.
45
56
This algorithm uses bitwise XOR to cancel out duplicate numbers.
6-
7-
>>> single_number([2, 2, 1])
8-
1
9-
>>> single_number([4, 1, 2, 1, 2])
10-
4
11-
>>> single_number([1])
12-
1
137
"""
148
res = 0
159
for n in nums:
1610
res ^= n
1711
return res
1812

19-
2013
if __name__ == "__main__":
2114
example = [4, 1, 2, 1, 2]
2215
print(single_number(example)) # Output: 4

0 commit comments

Comments
 (0)