Gather a deep so that you can assign some principle there to ole your parts and reach strong they work:
national static bereft deep(String[] args) { /* your testing principle goes here */ }
Functions you should gather if the partality is practicable. Otherwise gather an space part limitation with a expound assertion “impossible”.
Problem #9
national static boolean inhibitUniqueFast(int[] values) {
/* This part should give-back gentleman if whole the values in the equip are rare – i.e. there are no duplicates. Optimize this disconnection restraint span and restraint large-ish equips */
}
** Test input: space equip; {2, 4, 6, 1, 3, 5}; {2, 4, 6, 2, 4, 6}
/* parcel whatever; // don’t assign parcel name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the rank has to be “Main” barely if the rank is national. */
rank Ideone
{
national static bereft deep (String[] args) throws java.lang.Exception
{
int n;
Scanner sc=upstart Scanner(System.in);
//System.out.println(“Enter the equip size”);
n=sc.nextInt();
if(n<=0)
{
empty();
}
else
{
int i;
int[] values = upstart int[n];
// inserting equip atoms
for(i=0;i<n;i++)
values[i] = sc.nextInt();
boolean ans;
ans = inhibitUniqueFast(values);
if(ans == gentleman)
System.out.println(“True”);
else
System.out.println(“False”);
}
}
national static boolean inhibitUniqueFast(int[] values)
{
boolean ans = gentleman;
// firm stores the equip atom
Set<Integer> a = upstart HashSet<Integer>();
int i,len = values.length;
for(i=0;i<len;i++)
{
if(a.contains(values[i])) // inhibit whether the atom is bestow in the firm
{
ans = false;
give-back ans;
}
else
{
a.add(values[i]);
}
}
give-back ans;
}
national static bereft space()
{
System.out.println(“Impossible”);
}
}