Given two integers X and N. The task is to find the total number of ways of selecting X men from a group of N men with or without including a particular man.
Input: N = 3 X = 2
Including a man say M1, the ways can be (M1, M2) and (M1, M3).
Excluding a man say M1, the only way is (M2, M3).
Total ways = 2 + 1 = 3.
Input: N = 5 X = 3
Approach: The total number of ways of choosing X men from N men is NCX
- Including a particluar man: We can choose (X – 1) men from (N – 1) in N – 1CX – 1.
- Excluding a particular man: We can choose X men from (N – 1) in N – 1CX
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Ways of selecting men and women from a group to make a team
- Ways to form a group from three groups with given constraints
- Ways of dividing a group into two halves such that two elements are in different groups
- Total ways of choosing X men and Y women from a total of M men and W women
- Total number of ways to place X and Y at n places such that no two X are together
- Number of ways to sum up a total of N from limited denominations
- Ways to form an array having integers in given range such that total sum is divisible by 2
- Minimize the cost of selecting two numbers whose product is X
- Predict the winner of the game on the basis of absolute difference of sum by selecting numbers
- Convert Decimal To Hexa-Decimal including negative numbers
- Count of contiguous subarrays possible for every index by including the element at that index
- Group all co-prime numbers from 1 to N
- Find sum of N-th group of Natural Numbers
- Count of groups among N people having only one leader in each group
- Nicomachus’s Theorem (Sum of k-th group of odd positive numbers)
- Minimize the sum of the squares of the sum of elements of each group the array is divided into
- Number Theory | Generators of finite cyclic group under addition
- Total no of 1's in numbers
- Find the total Number of Digits in (N!)N
- Count total divisors of A or B in a given range