@@ -24,22 +24,22 @@ private CountBitsFlip() {
2424 }
2525
2626 /**
27- * Counts the number of bits that need to be flipped to convert A to B
27+ * Counts the number of bits that need to be flipped to convert a to b
2828 *
2929 * Algorithm:
30- * 1. XOR A and B to get positions where bits differ
30+ * 1. XOR a and b to get positions where bits differ
3131 * 2. Count the number of set bits in the XOR result
3232 * 3. Use Brian Kernighan's algorithm: n & (n-1) removes rightmost set bit
3333 *
34- * @param A the source number
35- * @param B the target number
34+ * @param a the source number
35+ * @param b the target number
3636 * @return the number of bits to flip to convert A to B
3737 */
38- public static long countBitsFlip (long A , long B ) {
38+ public static long countBitsFlip (long a , long b ) {
3939 int count = 0 ;
4040
4141 // XOR gives us positions where bits differ
42- long xorResult = A ^ B ;
42+ long xorResult = a ^ b ;
4343
4444 // Count set bits using Brian Kernighan's algorithm
4545 while (xorResult != 0 ) {
@@ -51,13 +51,13 @@ public static long countBitsFlip(long A, long B) {
5151 }
5252
5353 /**
54- * Alternative implementation using Long.bitCount()
54+ * Alternative implementation using Long.bitCount().
5555 *
56- * @param A the source number
57- * @param B the target number
58- * @return the number of bits to flip to convert A to B
56+ * @param a the source number
57+ * @param b the target number
58+ * @return the number of bits to flip to convert a to b
5959 */
60- public static long countBitsFlipAlternative (long A , long B ) {
61- return Long .bitCount (A ^ B );
60+ public static long countBitsFlipAlternative (long a , long b ) {
61+ return Long .bitCount (a ^ b );
6262 }
6363}
0 commit comments