Back to Cosmos

Cosmos

code/dynamic_programming/src/no_consec_ones/README.md

latest485 B
Original Source

Cosmos

No Consecutive Ones

Problem Statement

Given a length `n`, determine the number of binary strings of length `n` that have no consecutive ones.

For example, for `n=3`, the strings of length `3` that have no consecutive ones are `000,001,010,100,101`, 
so the algorithm would return `5`.

Expected time complexity: `O(2*n)`, where n is the length of the binary string with no consecutive ones.

Collaborative effort by OpenGenus