Skip to content

Commit 66af9cb

Browse files
committed
Algorithm solving problem "136. Single Number" from Leetcode (https://leetcode.com/problems/single-number/)
1 parent 09a990b commit 66af9cb

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Diff for: bit_manipulation/single_number.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ def single_number(nums: list) -> int:
1515
every element appears twice except for one.
1616
:return: element that appears only one time
1717
18-
Examples:
18+
Examples:
1919
Example 1
20-
Input: nums = [1, 3, 3, 2, 6, 2, 1]
21-
Output: 6
20+
>>> print(single_number([1, 3, 3, 2, 6, 2, 1]))
21+
6
22+
2223
Example 2
23-
Input: nums = [12, 1, 1, 7, 1, 12, 1]
24-
Output: 7
24+
>>> print(single_number([12, 1, 1, 7, 1, 12, 1]))
25+
7
26+
2527
Example 3
26-
Input: nums = [6]
27-
Output: 6
28+
>>> print(single_number([6]))
29+
6
2830
"""
29-
result = 0
3031

32+
result = 0
3133
for el in nums:
3234
result ^= el
33-
3435
return result

0 commit comments

Comments
 (0)