fbaquant / LeetCode

1 stars 0 forks source link

Count Distinct Numbers on Board #138

Open juneharold opened 3 months ago

juneharold commented 3 months ago

There will be n-1 numbers. x%i==1 means that i could be x-1. Therefore, there will be n-1 after first turn, n-2 after second turn, and so on. Eventually, all numbers from 2 to n are present on the board.

class Solution:
    def distinctIntegers(self, n: int) -> int:
        return n-1 if n > 1 else n