Given an array A[] of integers. Your task is to output the count of triplets such that in each triplet, there can be at most 2 same elements....
Given n cities connected by (n-1) roads, each specified by [a, b, type], denoting a connection between cities a and b of a certain ‘type’ (0 for normal roads, 1 for highways). The task is to count the number of trips satisfying two conditions:...
Given an array balls[] representing the count of colored balls labeled from 1 to k, the task is to determine the number of ways to draw the last ball of color i before drawing the last ball of color i + 1 for all i from 1 to k – 1....
Given an integer N, the task is to tile a board of dimensions N * 1 the task is to count the number of ways to tile a board using tiles of dimensions 1 * 1 and 2 * 1....
Given two positive integers N and K, the task is to find the mean of the minimum of all possible subsets of size K from the first N natural numbers....
Given an array arr[] of size N, the task is to count the number of pairs from the given array whose product contains only a single distinct prime factor....
Given an array arr[] consisting of N integers, the task is to count the total number of pairs of array elements from the given array such that arr[i] * arr[j] is the power of 2....
Given a number x, print all possible non-increasing sequences with sum equals to x....
Given two integers N, M denoting N×M chessboard, the task is to count the number of ways a knight can reach (N, M) starting from (0, 0). Since the answer can be very large, print the answer modulo 109+7....
Given an integer N representing a non-linear equation of the form 2X + 5Y = N, the task is to find an integral pair (X, Y) that satisfies the given equation. If multiple solutions exist, then print any one of them. Otherwise, print -1....
Given an integer X and integer N, the task is to find the number of unique paths starting from the root in N-ary tree such that the sum of all these paths is equal to X. The N-ary tree satisfies the following conditions:...
Given an array of pairs arr[] of size N (N ? 3) where each element of pair is at most N and each pair is unique, the task is to determine the number of ways to select triplets from the given N pairs that satisfy at least one of the following conditions:...