LeetCode 136: Single Number Without Growing Extra Storage
Problem Requirement You are given a non-empty integer array nums. Exactly one element appears once. Every other element appears exactly twice. Return the element that appears once. LeetCode provides this method contract: singleNumber(nums: List[int]) -> int The solution must also satisfy two resource requirements: O(n) time O(1) extra space Example 1 Input: nums = [2,2,1] Output: 1 2 appears twice. Only 1 appears once. Example 2 Input: nums = [4,1,2,1,2] Output: 4 Both 1 and 2 have matching copies. Only 4 remains unpaired. ...