FunctionRacerProblemsRace

No Adjacent Ones

EasyDynamic programmingPython, JavaScript, TypeScript, Java, C++

Count the binary strings of length n (made of 0 and 1) that never contain two 1 characters next to each other.

Example 1

n 3
returns 5

000, 001, 010, 100, 101: 5 strings.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Dynamic programming problems