Copied to Clipboard
Geek and his Binary Strings
Easy Accuracy: 29.96% Submissions: 2941 Points: 2

Given an integer N, the task is to find the number of binary strings of size 2*N in which each prefix of the string has more than or an equal number of 1's than 0's.

Note: The answer can be very large. So, output answer modulo 109+7

Example 1:

Input: N = 2
Output: 2
Explanation: 1100, 1010 are two 
such strings of size 4
Example 2:
Input: N = 3
Output: 5
Explanation: 111000 101100 101010 110010 
110100 are such 5 strings

Your Task:  
You don't need to read input or print anything. Complete the function prefixStrings() which takes N as input parameter and returns an integer value.

Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(|N|)

1 ≤ |N| ≤ 103

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Geek and his Binary Strings

Output Window