Showing:
Handle Score
@Ibrahim Nash 6379
@mb1973 5358
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Count binary strings
Easy Accuracy: 16.45% Submissions: 220 Points: 2

Given two integers n and k, count the number of binary strings of length n where adjacent 1 appear k times.

Example 1:

Input:
n = 3 , k = 2
Output: 1
Explanation: Possible string is "111".


â€‹Example 2:

Input:
n = 5 , k = 2
Output: 6
Explanation: Possible strings are:
"00111" , "10111" , "01110"
"11100" , "11101" , "11011".


You don't need to read input or print anything. Your task is to complete the function countStrings() which accepts integers n and k as input parameter and returns the number of binary strings that satisfy the given condition.

Expected Time Complexity: O(n*k).
Expected Auxiliary Space: O(n*k).

Constraints:
1 <= n, k <= 103