Count ways to divide circle using N non | Java code to count ways to divide circle using N non - intersecting chords . ; n = no of points required ; dp array containing the sum ; returning the required number ; Driver function
import java . io . * ; class GFG { static int chordCnt ( int A ) { int n = 2 * A ; int [ ] dpArray = new int [ n + 1 ] ; dpArray [ 0 ] = 1 ; dpArray [ 2 ] = 1 ; for ( int i = 4 ; i <= n ; i += 2 ) { for ( int j = 0 ; j < i - 1 ; j += 2 ) { dpArray [ i ] += ( dpArray [ j ] * dpArray [ i - 2 - j ] ) ; } } return dpArray [ n ] ; } public static void main ( String [ ] args ) { int N ; N = 2 ; System . out . println ( chordCnt ( N ) ) ; N = 1 ; System . out . println ( chordCnt ( N ) ) ; N = 4 ; System . out . println ( chordCnt ( N ) ) ; } }