Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bit_manipulation/find_number_that_appears_only_once_in_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def find_single_number(nums):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: find_single_number. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: nums

'''
LeetCode 136: Single Number
https://leetcode.com/problems/single-number/description/

>>> find_single_number([1, 4, 1, 7, 9, 2, 9, 7, 2])
4
>>> find_single_number([1, 2, 4, 1, 4, 3, 2])
3
>>> find_single_number([4, 1, 2, 1, 2])
4
'''
single_num = 0

Check failure on line 14 in bit_manipulation/find_number_that_appears_only_once_in_array.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

bit_manipulation/find_number_that_appears_only_once_in_array.py:14:1: W293 Blank line contains whitespace
for i in nums:
single_num = single_num ^ i;

Check failure on line 16 in bit_manipulation/find_number_that_appears_only_once_in_array.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E703)

bit_manipulation/find_number_that_appears_only_once_in_array.py:16:36: E703 Statement ends with an unnecessary semicolon

Check failure on line 17 in bit_manipulation/find_number_that_appears_only_once_in_array.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

bit_manipulation/find_number_that_appears_only_once_in_array.py:17:1: W293 Blank line contains whitespace
return single_num

if __name__ == "__main__":
import doctest
doctest.testmod()
Loading