Skip to content

Commit c6be1bb

Browse files
authored
Create count-collisions-of-monkeys-on-a-polygon.py
1 parent ed56363 commit c6be1bb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(logn)
2+
# Space: O(1)
3+
4+
# combinatorics, fast exponentiation
5+
class Solution(object):
6+
def monkeyMove(self, n):
7+
"""
8+
:type n: int
9+
:rtype: int
10+
"""
11+
MOD = 10**9+7
12+
return (pow(2, n, MOD)-2)%MOD

0 commit comments

Comments
 (0)