2550. Count Collisions of Monkeys on a Polygon
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 29% Topics: Math, Recursion
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(logn)
# Space: O(1)
# combinatorics, fast exponentiation
class Solution(object):
def monkeyMove(self, n):
"""
:type n: int
:rtype: int
"""
MOD = 10**9+7
return (pow(2, n, MOD)-2)%MOD
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions