Comments

THANK YOU!

I have got a very interesting solution to this problem. I don't know how it got ACCEPTED but my solution is inspired by a similar problem in Codeforces ProblemSet

MY SOLUTION

int n;

cin>>n;

for(int i=1;i<(1<<n);i++){ cout<<(__builtin_popcount(i^(i-1)))<<" "; }

Can you kindly explain how is it working?

It was a very good contest.

can anyone tell me what is best time complexity in which problem C(1 2 1 3..) can be solved?

Link for Problem C