Count of ways to select exactly K non-disjoint ranges from given N ranges

#include using namespace std;  int nCr(int n, int r, int* f){    return f[n] / f[r] * f[n – r];}  int NumberOfWaysToChooseKRanges(int L[], int R[],                                int N, int K){        int f[N + 1];    f[0] = 1;          for (int i = 1; i = K – 1) {                                ans += nCr(Cnt, K – 1, f);            }                          Cnt++;        }        else {                        Cnt–;        }    }          return ans;}  int main(){        int N = 7, K = 3;    int L[] = { 1, 3, 4, 6, 1, 5, 8 };    int R[] = { 7, 8, 5, 7, 3, 10, 9 };          cout