Binary strings with no two 1s in a row
Consider strings of length 10 made of the symbols 0 and 1, such as 0100101001.
How many such strings contain no two 1s next to each other? Find the pattern for shorter lengths first, and explain the recursion.
Show a hint
Classify a valid string by its last symbol. If it ends in 0, what came before? If it ends in 1, what must come before that?
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
Sign in to join the discussion · reading is open to everyone
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.
Related questions
Climbing ten steps one or two at a time1, 1, 2, 5, 14, 42, what next?A hundred empty glasses and the dregs1, 3, 4, 7, 11, 18, what next?Most regions from four circles
All questions →