Maximize Number of Nice Divisors LeetCode solution in Python

1
MOD = 10**9 + 7
2

3

4
class Solution:
5
def maxNiceDivisors(self, n: int) -> int:
6
if n <= 2:
7
return n
8
i, c = divmod(n, 3)
9
if not c:
10
return pow(3, i, MOD)
11
return (self.maxNiceDivisors(n - 2) * 2) % MOD

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0