There is a regular convex polygon with n vertices. The vertices are labeled from 0 to n - 1 in a clockwise direction, and each vertex has exactly one monkey. The following figure shows a convex polygon of 6 vertices.
Simultaneously, each monkey moves to a neighboring vertex. A collision happens if at least two monkeys reside on the same vertex after the movement or intersect on an edge.
Return the number of ways the monkeys can move so that at least one collision happens. Since the answer may be very large, return it modulo 109 + 7.
Example 1:
Input: n = 3
Output: 6
Explanation:
There are 8 total possible movements.
Two ways such that they collide at some point are:
Example 2:
Input: n = 4
Output: 14
Constraints:
3 <= n <= 109Solutions for this problem are being prepared.
Try solving it yourself2550. Count Collisions of Monkeys on a Polygon | Weekly Contest 330 | LeetCode 2550 • Bro Coders • 2,266 views views
Watch 9 more video solutions →Practice Count Collisions of Monkeys on a Polygon with our built-in code editor and test cases.
Practice on FleetCode