# Combinatorial

### Count of ways to empty given String by recursively removing all adjacent duplicates

#include using namespace std;  int dp, choose;  int calc(int l, int r, string& s){          if (abs(r – l) % 2 == 0) {        return…

### Count of valid arrays of size P with elements in range [1, N] having duplicates at least M distance apart

#include using namespace std;  int calculate(int position, int used, int unused, int P,              int M, vector& dp){        if (position == P) {                        return unused…

### Count of even sum triplets in the array for Q range queries

#include using namespace std;  void countTriplets(int size, int queries,                   int arr[], int Q[]){          int arr_even[size + 1], arr_odd[size + 1];          int even = 0,…

### Sum of all subsets of a given size

Given an array arr[] consisting of N integers and a positive integer K, the task is to find the sum…

### Count of integers in given range having their last K digits are equal

Given a range from L to R and an integer K, the task is to count the number of integers…

### Count ways to make the number formed by K concatenations of a numeric string divisible by 5

Given a string S consisting of N digits and an integer K, the task is to count the number of…

### Count subsequence of length 4 having product of the first three elements equal to the fourth element

Given an array arr[] consisting of N positive integers, the task is to find the number of subsequences of length…

### Count of distinct permutation of a String obtained by swapping only unequal characters

Given a string find the number of unique permutations that can be obtained by swapping two indices such that the…