• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
December 14, 2023 |1.5K Views
PROBLEM OF THE DAY : 13/12/2023 | Consecutive 1's not allowed
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Array but also build up problem-solving skills.

In this problem, we are given, a positive integer N, and count all possible distinct binary strings of length N such that there are no consecutive 1’s. Output your answer modulo 109 + 7.

Example :

Input:
N = 3
Output: 5

Explanation:
5 strings are (000, 001, 010, 100, 101).

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/gold-mine-problem2608/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/7ba73f83-80a2-4e7c-980c-bfe2a1e79790