My issue
plz give me some approach
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static int minMoves(int A, int B) {
// Check if it's impossible to make them equal
if(A==B){
return 0;
}
// if ((A - B) % 4 != 0) {
// return -1;
// }
// Calculate the minimum number of moves using parity analysis
int diff = Math.abs(A - B);
if (diff % 2 == 0) {
return diff / 2;
} else {
return diff / 2 + 1;
}
}
public
static
void
main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt(); // Number of test cases
for (int i = 0; i < T; i++) {
int A = scanner.nextInt();
int B = scanner.nextInt();
int result = minMoves(A, B);
System.out.println(result);
}
}
}
Problem Link: Equality Etiquette Practice Coding Problem - CodeChef