Geek and his Binary Strings
Easy Accuracy: 30.77% Submissions: 13 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|)

Constraints:
1 ≤ |N| ≤ 103

to report an issue on this page.

Editorial

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

Yes

All Submissions

My Submissions:

Login to access your submissions.