Untitled

mail@pastecode.io avatar
unknown
python
2 months ago
373 B
4
Indexable
Never
class Solution:
    def countHousePlacements(self, n: int) -> int:
        x = 2
        y = 3 

        if n == 1:
            return x ** 2
        if n == 2:
            return y ** 2
        
        mod = 1000000007

        i = 3
        while i <= n:
            z = x + y
            x = y
            y = z
            i += 1
        
        return y ** 2 % mod

Leave a Comment