allcoding1
27.7K subscribers
2.2K photos
2 videos
74 files
850 links
Download Telegram
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
Telegram:- @allcoding1

Juspay

=int(input())
dic={}
def addnode(u,v):
dic[u].append(v)
for i in range(N):
n1=int(input())
dic[n1]=[]

edge=int(input())
for i in range(edge):
u,v=map(int,input().split())
addnode(u,v)
start=int(input())
end=int(input())
tr=[]
tr.append(start)
def traverse(dic,start):
for i in dic[start]:
if(i==end):
return
if(len(dic[start])==0):
return
else:
tr.append(i)
traverse(dic,i)

traverse(dic,start)
tr=sorted(tr)
for i in tr:
print(i,end=" ")
1
HCL is hiring Fresher

Apply link 👇

https://www.hcltech.com/jobs/senior-analyst-2
👍1
Willey edge