text: Number of ways to insert two pairs of parentheses into a string of N characters | C # implementation of the approach ; Function to return the number of ways to insert the bracket pairs ; Driver code
code: using System ; class GFG { static int cntWays ( String str , int n ) { int x = n + 1 ; int ways = x * x * ( x * x - 1 ) / 12 ; return ways ; } public static void Main ( String [ ] args ) { String str = " ab " ; int n = str . Length ; Console . WriteLine ( cntWays ( str , n ) ) ; } }