Single Number
easy · bit magic
You are given a list of integers `nums` in which every value appears exactly twice, except for one value that appears exactly once. Find and return that single value.
Input: `nums` (a list of integers).
Output: the integer that appears exactly once.
Example: nums = [4, 1, 2, 1, 2] -> 4.
Starter code
def single_number(nums: list[int]) -> int:
"""Return the element that appears exactly once."""
pass
Enable JavaScript to edit this code and run the hidden tests in your browser. Each test has a five-second execution limit. Your drafts and solved progress stay in this browser.
Return to the Python compiler