Question is

and my solution is

https://ide.geeksforgeeks.org/9kZe3KyD3W

What I think is

- calculate total number of bits;
- creater number by 1<<(total bits)

3.run a loop and take and with the given number

(i) if(number & with created number in step 2 is zero it means we find left unset bit then take OR of both and break;

(ii) Else Right shift the created number and get in Loop

Why there is TLE.

Edit 1. I know this is long approach but it is what that I think… Please Help