allcoding1
27.7K subscribers
2.2K photos
3 videos
74 files
850 links
Download Telegram
👍3
Accenture

Pseudo code
👍1🔥1
allcoding1
Photo
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
       
        int n = scanner.nextInt();
        int[] left = new int[n];
        int[] right = new int[n];
       
        for (int i = 0; i < n; i++) {
            left[i] = scanner.nextInt();
            right[i] = scanner.nextInt();
        }
       
        int sumLeft = 0;
        int sumRight = 0;
       
        for (int i = 0; i < n; i++) {
            sumLeft += left[i];
            sumRight += right[i];
        }
       
        if (sumLeft % 2 == 0 && sumRight % 2 == 0) {
            System.out.println(0);
            return;
        }
       
        boolean possible = false;
        for (int i = 0; i < n; i++) {
            int newSumLeft = sumLeft - left[i] + right[i];
            int newSumRight = sumRight - right[i] + left[i];
            if (newSumLeft % 2 == 0 && newSumRight % 2 == 0) {
                possible = true;
                break;
            }
        }
       
        if (possible) {
            System.out.println(1);
        } else {
            System.out.println(-1);
        }
    }
}
👍6
Nagging react newbie

Telegram:- @allcoding1