Add FirstDifferentBit algorithm (#5866)

This commit is contained in:
Hardik Pawar
2024-10-26 15:13:56 +05:30
committed by GitHub
parent 5d428d08a2
commit e4ef072f83
3 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
package com.thealgorithms.bitmanipulation;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
public class FirstDifferentBitTest {
@ParameterizedTest
@CsvSource({"10, 8, 1", "7, 5, 1", "15, 14, 0", "1, 2, 0"})
void testFirstDifferentBit(int x, int y, int expected) {
assertEquals(expected, FirstDifferentBit.firstDifferentBit(x, y));
}
}