Constant space complextity

actually in this problem constant space complexity was asked but sir said to make a list having set bit at 2nd position. so it does not have constant space complexity.

hello @priyansh781 constant space complexity means the variables that are storing some information.
and this code as a whole cannot be done in the constant space .
we need one array or list to store the set bit .
sir was talking about extra variables as to be covered in the constant space .
if you still have any doubt please ask here otherwise please mark this doubt as resolved.

Happy Learning !!

but the problem says we have to do it without using any extra space

where are you solving this problem ?

so the problem demands o(1) space complexity. but in our case we can have o(n) space complexity in worst case if from n numbers n-1 have the set bit

i was not solving but in the starting of the video it is written

@priyansh781 please see the code which i am giving you .


it is being solved in constant space otherwise if the space complexity is o(n) then we could have very easily solved it with the help of the arrays only or frequency count then there would have been no use of bit manipulation then .
please try to read and understand the code first .
and then do the analysis on the complexity .
if you still feel that you have doubt then we will discuss .
Happy Learning !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.