#136
Single Number
easy· Bit Manipulationruns: 0Given a non-empty array of integers nums where every element appears twice except for one, find that single one. The algorithm must run in linear time and use constant extra space.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 160
class Solution:
def singleNumber(self, nums: list[int]) -> int:
result = 0
for num in nums:
result ^= num
return result
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.