Practice Count Collisions of Monkeys on a Polygon
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
One monkey starts at each vertex of a regular n-sided polygon. All simultaneously choose one of their two neighboring vertices and move there. A collision means meeting at a destination or crossing along an edge. Count movement choices producing at least one collision, modulo 10^9 + 7.
Source: Count Collisions of Monkeys on a Polygon on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 3
Output
6
# Example 2
Input
n = 4
Output
14
Constraints
3 <= n <= 10^9
Related LeetCode Problems
Practice more problems similar to Count Collisions of Monkeys on a Polygon.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.