class MathUtil {

    public static ValueWithCount<Integer> mode(int[] values, int... valuesToIgnore)
    {
        int mode = 0;
        int count = 0;

        TIntIntHashMap countMap = new TIntIntHashMap();
        for (int value : values)
        {
            if (!countMap.containsKey(value))
            {
                countMap.put(value, 0);
            }
            countMap.increment(value);
        }

        for (int value : countMap.keys())
        {
            if (!contains(valuesToIgnore, value))
            {
                int thisCount = countMap.get(value);
                if (thisCount > count)
                {
                    mode = value;
                    count = thisCount;
                }
            }
        }

        return new ValueWithCount<>(Integer.valueOf(mode), count);
    }

    private  MathUtil();

}