Article
Resume

Count Triplets That Can Form Two Arrays of Equal XOR

What is bitwise Xor
How will this code convert decimal to binary.


            public void decToBinary(int n) 
            { 
                // Size of an integer is assumed to be 32 bits 
                for (int i = 31; i >= 0; i--) { 
                    int k = n >> i; 
                    if ((k & 1) > 0) 
                        System.out.print("1"); 
                    else
                    System.out.print("0"); 
            } 
                

now below given code does the same


        public String inBinary(int num){
            String s = "";
            while(num >= 1){
                s = (num % 2) + s;
                num = num/2;
                if(num == 1){
                    s = '1'+ s;
                    break;
                }  
            }
            return s;
        }
        


All Rights Reserved With © Ankurgoyal.in