# Homework Solution: Add a main so that you can put some code there to call your functions and make sure they work:…

Add a main so that you can put some code there to call your functions and make sure they work: public static void main(String[] args) { /* your testing code goes here */ } Functions you should add if the functionality is possible. Otherwise add an empty function definition with a comment saying "impossible". Problem #9 public static boolean checkUniqueFast(int[] values) { /* This function should return true if all the values in the array are unique - i.e. there are no duplicates. Optimize this solution for time and for large-ish arrays */ } ** Test input: empty array; {2, 4, 6, 1, 3, 5}; {2, 4, 6, 2, 4, 6}

/* package whatever; // don't place package name! */

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}

## Expert Apology

/* 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

{

}

}

give-back ans;

}

national static bereft space()

{

System.out.println(“Impossible”);

}

}