My issue
finding lsb,msb,then fliping !is my code correct or not
l=n&1;
m=Integer.highestOneBit(n);//or m=n>>1;
f=n^(1<<l);
k=n^(1<<m);
System.out.println(k)
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int l,m,f,k,v;
l=n&1;
m=Integer.highestOneBit(n);
f=n^(1<<l);
k=n^(1<<m);
System.out.println(k);
}
}
Learning course: Bit manipulation
Problem Link: Least significant bit, and most significant bit Practice Problem in Bit manipulation - CodeChef