Posts

Showing posts from February, 2022

Make AP (codeforces 764)

 import java.util.*; public class MyClass {     public static void main(String args[]) {      Scanner sc=new Scanner(System.in);      int t=sc.nextInt();      while(t-->0){          int a=sc.nextInt();          int b=sc.nextInt();          int c=sc.nextInt();          int gap1=b-a;          int gap2=c-b;          if(gap1==gap2){              System.out.println("YES");             continue;          }           if((a+c)%2==0){              int y=(a+c)/2;          if(y%b==0){               System.out.println("YES");            continue;   ...

EQUAL MEX

 /* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){     int n=sc.nextInt();     HashMap<Integer,Integer> hm=new HashMap<>();     int x=2*n;     while(x-->0){         int p=sc.nextInt();         if(!hm.containsKey(p)){             hm.put(p,1);         }         else{             hm.put(p,hm.get(p)+1);         }     }     for(int i=0;i<=n;i++){         Integer freq=h...