Colorful Strings
Easy Accuracy: 52.76% Submissions: 699 Points: 2

Find the count of all possible strings of size n.Each character of the string is either ‘R’, ‘B’ or ‘G’. In the final string there needs to be at least r number of ‘R’, at least b number of ‘B’ and at least g number of ‘G’ (such that r + g + b <= n).

Example 1:

Input: n = 4, r = 1, g = 1, b = 1
Output: 36
Explanation: No. of 'R' >= 1,
No. of ‘G’ >= 1, No. of ‘B’ >= 1
and (No. of ‘R’) + (No. of ‘B’)
+ (No. of ‘G’) = n then
following cases are possible:
1. RBGR and its 12 permutation
2. RBGB and its 12 permutation
3. RBGG and its 12 permutation


Example 2:

Input: n = 4, r = 2, g = 0, b = 1
Output: 22
Explanation: No. of 'R' >= 2,
No. of ‘G’ >= 0, No. of ‘B’ >= 1
and (No. of ‘R’) + (No. of ‘B’)
+ (No. of ‘G’) <= n then
following cases are possible:
1. RRBR and its 4 permutation
2. RRBG and its 12 permutation
3. RRBB and its 6 permutation
Hence answer is 22.

You dont need to read input or print anything. Complete the function possibleStrings() which takes n, r, g, b as input parameter and returns the count of number of all possible strings.
.

Expected Time Complexity: O(n2)
Expected Auxiliary Space: O(n)

Constraints:
1<= n <=20
1<= r+b+g <=n

We are replacing the old Disqus forum with the new Discussions section given below.