Skip to content

Commit

Permalink
Create count-collisions-of-monkeys-on-a-polygon.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 authored Jan 30, 2023
1 parent ed56363 commit c6be1bb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Python/count-collisions-of-monkeys-on-a-polygon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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

0 comments on commit c6be1bb

Please sign in to comment.