@@ -0,0 +1,1500 @@
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0A%0A// https://www.hackerrank.com/challenges/flipping-bits/problem%0Apublic class FlippingBits %7B%0A%0A  private static String addLeadingZeros(String bits) %7B%0A    while (bits.length() %3C 32) %7B%0A      bits = %220%22 + bits;%0A    %7D%0A    return bits;%0A  %7D%0A%0A  private static String toBits(long number) %7B%0A    String bits = Long.toBinaryString(number);%0A    return addLeadingZeros(bits);%0A  %7D%0A%0A  private static String flipBits(String bits) %7B%0A    String flippedBits = %22%22;%0A    for (char bit : bits.toCharArray()) %7B%0A      char flipped = (bit == '0') ? '1' : '0';%0A      flippedBits += flipped;%0A    %7D%0A    return flippedBits;%0A  %7D%0A%0A  private static long toUnsignedNumber(String bits) %7B%0A    return Long.parseUnsignedLong(bits, 2);%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) %7B%0A      int cases = Integer.parseInt(reader.readLine());%0A      for (int i = 0; i %3C cases; i++) %7B%0A        /*%0A         * Why do we use long instead of int? Because in Java there are signed integers only.%0A         * So if we get 2%5E31 + 1 as input, that value is greater than Integer.MAX_VALUE.%0A         */%0A        long inputCase = Long.parseLong(reader.readLine());%0A        String bits = toBits(inputCase);%0A        String flippedBits = flipBits(bits);%0A        long result = toUnsignedNumber(flippedBits);%0A        System.out.println(result);%0A      %7D%0A    %7D%0A  %7D%0A%7D%0A

Add solution for Flipping bits problem.