If you are talking about this solution, It is failing because your code is giving “-1” on when N==1, but correct answer is “1” at input “1”.
Which you have corrected here.
The mistake which you made was in this part:
if (a != 0 && (a & (a - 1)) == 0)
cout << -1 <<endl;
else if (a == 1)
cout << 1 <<endl;
Here you are checking if N is power of 2, So 1 is basically power of 2 so it will cout “-1”
But in correct solution you are checking:
cin >> n;
if (n == 1)
cout << 1 << endl;
You are checking if n is 1 then you are doing cout “1” which is correct.
You can see by giving input 1 in both partial and correct solutions.
I used your correct solution with N = 1: https://ideone.com/QSUO63
I used your partial solution with N = 1: https://ideone.com/Y3grUf
Getting different values for N = 1.