#268
Missing Number
easy· Bit Manipulationruns: 0Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 187
class Solution:
def missingNumber(self, nums: list[int]) -> int:
result = len(nums)
for i, num in enumerate(nums):
result ^= i ^ 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.