[Solved] generate all possible strings with 0 and 1 (given length)


You can try something with 2^N (N can takes as length ). Then convert 0-2^N to binary and use proper binary formating. The you can have what you looking for.

First step- get 2^N

double twosPow = Math.pow(2, occurrence);

Now iterate from 0 up to twosPow. and convert number to binary

Second step- how to convert int to binary?

Integer.toBinaryString(k); // 0<=k<  twosPow

Third step- format binary

String.format("%" + length + "s",binary).replace(" ", "0") 

0

solved generate all possible strings with 0 and 1 (given length)