public static ArrayList<Integer> getMinCoins2(int[] denoms, int sum)
    {
        ArrayList<Integer> vals = new ArrayList();
        
        if (sum == 0)
        {
            return vals;
        }
        
        if (sum <= -1)
        {
            return null;
        }
        
        ArrayList<ArrayList<Integer>> allVals = new ArrayList();
        
        for (int d : denoms)
        {
            if (d <= sum)
            {
                vals = new ArrayList();
                vals.add(d);
                ArrayList<Integer> ret = getMinCoins2(denoms,sum - d);
                if (ret != null)
                {
                    vals.addAll(getMinCoins2(denoms,sum - d));
                    allVals.add(vals);
                }
            }
        }
        
        ArrayList<Integer> toRet = null;
        if (allVals.size() > 0)
        {
            int min = allVals.get(0).size();
            toRet = allVals.get(0);
            for (ArrayList<Integer> a : allVals)
            {
                if (a.size() < min)
                {
                    min = a.size();
                    toRet = a;
                }
            }
        }
        
        return toRet;
    
    }