Swap Bits Geeks For Geeks
Problem Link: https://practice.geeksforgeeks.org/problems/swap-bits5726/1# (It is also the problem of day for 29-03-2022) Solution: class Solution{ int swapBits(int x, int p1, int p2, int n) { String s=String.format("%31s", Integer.toBinaryString(x)).replaceAll(" ", "0"); //System.out.println(s); StringBuilder sb=new StringBuilder(s); /* for(int i=0;i<s.length();i++){ sb.append(s.charAt(i)); }*/ //System.out.println(sb); int count=0; int a=30-p1; int b=30-p2; while(count!=n){ char a1=s...