This problem simply states that we have to print all permutation of binary number of length N with M number of 1’s. Let us see the below example test case.

Test case explanation
N is 4  ( it means 4 length of binary number)
M is 2 ( it means number of 1’s in binary number)
Look at the first output ( 0011) , the last two digit of first output is 1 1. The next output is the all combinations of first output.

How to solve:
(1) take a string of length N , filled with 0.
(2) Append 1 1 to the end of the string.
(3) Print all combinations of string ( achieved at step 2).

Problem link:


Related Contents to follow