Intersecting Chords in a Circle
Given a number A, return number of ways you can draw A chords in a circle with 2 x A points such that no 2 chords intersect.
Two ways are different if there exists a chord which is present in one way and not in other.
Return the answer modulo 109 + 7.
Input Format:
Output Format:
Constraints:
Examples:
Explaination:
If we draw a chord between any two points, can you observe current set of points getting broken into two smaller sets S_1 and S_2? Can a chord be drawn between two points where each point belong to different set?
If we draw a chord from a point in S_1 to a point in S_2, it will surely intersect the chord we’ve just drawn.
So, we can arrive at a recurrence that Ways(n) = sum[i = 0 to n-1] { Ways(i)*Ways(n-i-1) }. Here we iterate over i, assuming that size of one of the sets is i and size of other set automatically is
(n-i-1) since we’ve already used a pair of points and i pair of points in one set.
Last updated