LeetCode solutions

2679. Count Distinct Numbers on Board

My accepted Python solution to LeetCode problem 2679, Count Distinct Numbers on Board, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.1MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.1MB, accepted 2026-01-01.

python
class Solution:
    def distinctIntegers(self, n: int) -> int:
        # For any x >= 2, x % (x-1) == 1
        # So we'll eventually add all numbers from 2 to n
        # Only exception: if n == 1, we can't add anything
        return max(1, n - 1)

Source