# WA in CHEFRECP

Question:

My Solution:
https://www.codechef.com/viewsolution/33313592

consider the case
1
10
1 1 4 3 4 4 4 7 7 7

but your solution will output â€śYESâ€ť.

1 Like

``````from itertools import groupby
for i in range(int(input())):
n = int(input())
c = 0
a = list(map(int, input().split()))
g = sorted(a)
b = [len(list(group)) for key, group in groupby(a)]
h = [len(list(group)) for key, group in groupby(g)]
b = sorted(b)
h = sorted(h)
#print(b)
#print(h)
if(b == h):
#print(b)
#b = sorted(b)
d = [len(list(group)) for key, group in groupby(b)]
#for i in range(len(b)-1):
#       if(b[i] == b[i+1]):
#          c = 0
# else:
#     c = 1
for i in d:
if(i > 1):
c = 1
#print(c)
if(c == 1):
print("NO")
else:
print("YES")
else:
print("NO")``````

Please help me i couldnâ€™t figure out why my code is showing WA while submitting but all the test cases are getting passed.

import java.util.;
import java.io.
;
class Codechef
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int p=0;p<t;p++)
{
boolean b=true;

``````        int n=sc.nextInt();
Integer[] arr=new Integer[n+1];
HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
List< Integer> list =new ArrayList<Integer>();
for(int i=1;i<=n;i++)
{
arr[i]=sc.nextInt();

if( list.contains(arr[i]))
{
if(arr[i-1]!=arr[i])
{
b=false;
}
map.put(arr[i],map.get(arr[i])+1);
//System.out.println("--"+map.get(arr[i]));
}
else
{
// System.out.println("+++"+arr[i]);
map.put(arr[i],1);
}
}
List<Integer> list2=new ArrayList<Integer>();
for (int j : map.keySet()) {
if(list2.contains(map.get(j)))
{
//  System.out.println("NO");
b=false;
// break;
}

}
if(b==true)
{
System.out.println("YES");
}
else{
System.out.println("NO");

}

}
}
``````

}

Thanks!