Description
Solutions
Number of Balanced Strings
🔥 FULLTIME🤘 INTERN

Write a Java program with a function named numberOfBalancedStrings that counts the number of ways we can make a balanced string of size n and difference d.

A Balanced string is a string where the difference between adjacent characters does not exceed d.

Example 1:

Input:  n = 3, d = 3
Output: 224
Explanation:

There are 224 ways to create a balanced string of size 3 with a maximum adjacent character difference of 3.

Example 2:

Input:  n = 2, d = 2
Output: 124
Explanation:

There are 124 ways to create a balanced string of size 2 with a maximum adjacent character difference of 2.

Constraints:
    N/A
Thumbnail 0
Testcase

Result
Case 1

input:

output: