Layman's conversion method: Decimal to binary, complement and back to Decimal
Long approach.\nNot used any Math.func , XOR, Bit manipulation.\n1.Convert Decimal to binary.\n2.Take its compliment\n3.Convert back to equivalent Decimal.\n\n\
Long approach.\nNot used any Math.func , XOR, Bit manipulation.\n1.Convert Decimal to binary.\n2.Take its compliment\n3.Convert back to equivalent Decimal.\n\n```\nclass Solution {\n    public int findComplement(int num) {\n        int sum=0;\n        List<Integer> n = new ArrayList<Integer>();\n        //Convert Decimal to Binary\n        while(num!=0)\n        {\n            n.add(num%2);\n            num = num/2;\n            if(num==1)\n            {\n                n.add(num);\n                num=0;\n            }       \n        }\n        //Complement it\n        for(int i=0;i<n.size();i++)\n        {\n            if(n.get(i)==1)\n            {\n                n.set(i,0);\n            }else\n            {\n                n.set(i,1);\n            }\n        }\n        //Convert back to decimal\n        int count=1;\n        for(int i=0;i<n.size();i++)\n        {\n             sum += n.get(i)*count;\n             count *= 2;\n        }\n        return sum;\n    }\n}\n```
[]