
public class ListHelp {


    public static int[] irredundantNonzero(int[] LIST) {
	int L=LIST.length;
	int count=0;
	int[] LIST2=new int[L];
	
	for(int i=0;i<L;++i) {
	    boolean test=onListNonzero(LIST[i],LIST2,count);
	    if(test==false) {
		LIST2[count]=LIST[i];
		++count;
	    }
	}
	return trim(LIST2,count);
    }

    public static boolean onListNonzero(int q,int[] a,int n) {
	if(q==0) return true;
	for(int i=0;i<n;++i) {
	    if(q==a[i]) return true;
	}
	return false;
    }




    public static int[] irredundant(int[] LIST) {
	int L=LIST.length;
	int count=0;
	int[] LIST2=new int[L];
	
	for(int i=0;i<L;++i) {
	    boolean test=onList(LIST[i],LIST2,count);
	    if(test==false) {
		LIST2[count]=LIST[i];
		++count;
	    }
	}
	return trim(LIST2,count);
    }

    public static boolean onList(int q,int[] a,int n) {
	for(int i=0;i<n;++i) {
	    if(q==a[i]) return true;
	}
	return false;
    }

    
    
    public static int[] trim(int[] a,int count) {
	int[] b=new int[count];
	for(int i=0;i<count;++i) b[i]=a[i];
	return b;
    }

    public static int lookup(int k,int[] LIST) {
	for(int i=0;i<LIST.length;++i) {
	    if(LIST[i]==k) return i;
	}
	return -1;
    }

    
    public static void print(int[] a) {
	for(int i=0;i<a.length;++i) System.out.print(a[i]+"  ");
	System.out.println("");
    }
    public static void print(int[] a,int l) {
	for(int i=0;i<l;++i) System.out.print(a[i]+"  ");
	System.out.println("");
    }
}
