Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
int tmp;
vector<int>occ(n+1,0);
for(int i=0; i<2*n; i++) {
cin>>tmp;
occ[tmp]++;
}
int smallest = n+1;
for(int i=0; i<=n; i++) {
if(occ[i] == 0) {
smallest = i;
break;
}
}
if(smallest == n+1) {
cout<<"NO\n";
continue;
}
bool ans = true;
for(int i=0; i<smallest; i++) {
if(occ[i]<2) {
ans = false;
break;
}
}
if(ans) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin>>T;
while(T--)
{
int N;
cin>>N;
int A[2*N];
map<int,int>mp;
for(int i = 0; i < 2*N; i++)
{
cin>>A[i];
mp[A[i]]++;
}
int i=0;
bool flag = 1;
for(auto it : mp)
{
if(it.first==i)
{
if(it.second<2)
{
flag = 0;
break;
}
}
i++;
}
(flag) ? cout<<"YES" : cout<<"NO";
cout<<endl;
}
return 0;
}
# cook your dish here
from collections import defaultdict
for _ in range(int(input())):
N = (2*int(input()))
A = sorted(list(map(int, input().split()))); cnt = i = 0
while i < N:
cn = 0
while i < N and A[i] == cnt:
cn += 1
i += 1
if cn == 1: print("NO"); break
if cn == 0: print("YES"); break
cnt += 1
else:
print("YES")
#include <stdio.h>
int main()
{
long long int T,i,N,j,C,k;
scanf("%lld",&T);
for(i=0;i<T;i++){
scanf("%lld",&N);
long long int A[N+1];
for(j=0;j<=N;j++){
A[j]=0;
}
for(j=0;j<2*N;j++){
scanf("%lld",&C);
A[C]=A[C]+1;
}
for(k=0,j=0;j<=N;j++){
if(A[j]==0){
break;
}
else if(A[j]==1){
k=1;
break;
}
}
(k==0)?(printf("YES\n")):(printf("NO\n"));
}
return 0;
}
/* 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 int solve(){
int res=0;
return res;
}
public static void main (String[] args) throws java.lang.Exception
{
PrintWriter out = new PrintWriter(System.out);
Scanner sc = new Scanner(System.in);
int testCases = sc.nextInt();
while(testCases-->0){
int n = sc.nextInt();
TreeMap<Integer,Integer> map = new TreeMap<>();
for(int i=0;i<2*n;i++){
int x = sc.nextInt();
map.put(x,map.getOrDefault(x,0)+1);
}
boolean ans = true;
int st = 0;
for(int key : map.keySet()){
if(key != st++) break;
int x = map.get(key);
if(x == 1) {
ans = false;
break;
}
}
if(ans) out.println("YES");
else out.println("NO");
}
out.close();
}
}
testcases = int(input())
for eachcase in range(testcases):
length = int(input())
array = list(map(int, input().split()))
hashmap = {}
for nums in array:
hashmap[nums] = 1 + hashmap.get(nums, 0)
currmin = min(array)
if currmin == 0:
while True:
count = hashmap.get(currmin, 0)
if count == 0:
print("YES")
break
if count < 2:
print("NO")
break
currmin += 1
else:
print("YES")
t = int(raw_input())
for i in range(t):
N = int(raw_input())
st = raw_input().split()
A = []
for x in st:
A.append(int(x))
# endfor x
A.sort()
A.append(10**6)
found = True
cnt = 1
n = 0
p = 0
while found and (cnt > 0):
cnt = 0
while A[p] == n:
cnt += 1
p += 1
# endwhile
if cnt == 1:
found = False
# endif
n += 1
# endwhile
if found:
print 'YES'
else:
print 'NO'
# endif
# endfor i
using System;
class Program
{
void Solve()
{
int n=int.Parse(Console.ReadLine());
string[] nr=Console.ReadLine().Split(' ');
int[] v = new int[2*n];
for(int i=0;i<n*2;i++)
{
v[i]=int.Parse(nr[i]);
}
Array.Sort(v);
int mex=0;
int freq=0;
for(int i=0;i<n*2;i++)
{
if(v[i]==mex)
{
freq++;
if(freq==2)
{
freq=0;
mex++;
}
}
}
if(freq==0)Console.WriteLine("YES");
else Console.WriteLine("NO");
}
static void Main()
{
int t=int.Parse(Console.ReadLine());
while(t>0)
{
t--;
new Program().Solve();
}
}
}
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString
.trim()
.split("\n")
.map((string) => {
return string.trim();
});
main();
});
function readline() {
return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();
function main() {
let T = parseInt(readline());
while(T--){
let n = parseInt(readline(), 10);
let arr = readline().split(" ").map(s => parseInt(s, 10));
const has = {}
for(let i=0; i < arr.length; i++){
if (has[arr[i]]) {
has[arr[i]]+=1
} else {
has[arr[i]] = 1
}
}
for(let i=0; i<=n; i++){
if (!has[i]) {
console.log("YES");
break;
} else {
if(has[i] == 1) {
console.log("NO");
break
}
}
}
//console.log(has);
}
return 0;
}
package main
import (
"bufio"
"bytes"
"fmt"
"os"
"sort"
)
func main() {
reader := bufio.NewReader(os.Stdin)
tc := readNum(reader)
var buf bytes.Buffer
for tc > 0 {
tc--
n := readNum(reader)
arr := readNNums(reader, 2*n)
res := solve(arr)
if res {
buf.WriteString("YES\n")
} else {
buf.WriteString("NO\n")
}
}
fmt.Print(buf.String())
}
func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}
func readString(reader *bufio.Reader) string {
s, _ := reader.ReadString('\n')
for i := 0; i < len(s); i++ {
if s[i] == '\n' {
return s[:i]
}
}
return s
}
func readNum(reader *bufio.Reader) (a int) {
bs, _ := reader.ReadBytes('\n')
readInt(bs, 0, &a)
return
}
func readTwoNums(reader *bufio.Reader) (a int, b int) {
res := readNNums(reader, 2)
a, b = res[0], res[1]
return
}
func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
res := readNNums(reader, 3)
a, b, c = res[0], res[1], res[2]
return
}
func readNNums(reader *bufio.Reader, n int) []int {
res := make([]int, n)
x := 0
bs, _ := reader.ReadBytes('\n')
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
x = readInt(bs, x, &res[i])
}
return res
}
func readUint64(bytes []byte, from int, val *uint64) int {
i := from
var tmp uint64
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + uint64(bytes[i]-'0')
i++
}
*val = tmp
return i
}
func solve(arr []int) bool {
// n := len(arr) / 2
sort.Ints(arr)
// first no existing number or single number is the mex
var mex int
var i int
for i < len(arr) {
if arr[i] > mex {
return true
}
j := i
for i < len(arr) && arr[i] == arr[j] {
i++
}
if i-j == 1 {
return false
}
mex++
}
return true
}
In our experience, we suggest you solve this Equal MEX CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Equal MEX CodeChef Solution.
I hope this Equal MEX CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.
Keep Learning!