137-Single-Number-Ii

Sat 17 May 2025

https://leetcode.com/problems/single-number-ii

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def singleNumber(self, nums: List[int]) -> int:
    ones = 0
    twos = 0

    for num in nums:
      ones ^= num & ~twos
      twos ^= num & ~ones

    return ones
new Solution().singleNumber()

Score: 5

Category: leetcode