public int getNumberOfBins(final List<Long> items) {

        final int totalItem = items.size();
        if (totalItem == 0) {
            return 0;
        }
        // list of bins
        final List<Bin> bins = new ArrayList<Bin>();
        for (int i = 0; i < totalItem; i++) {
            long min = 1;
            int binIndex = 0;
            for (int j = 0; j < bins.size(); j++) {
                if (bins.get(j).capacity < items.get(i)) {
                    continue;
                }
                if ((bins.get(j).capacity - items.get(i)) < min) {
                    min = bins.get(j).capacity - items.get(i);
                    binIndex = j;
                }
            }
            final Bin bin;
            if (min == 1) {
                bin = new Bin();
                bins.add(bin);
            } else {
                bin = bins.get(binIndex);
            }
            bin.weights.add(items.get(i));
            bin.capacity -= items.get(i);
        }

        return bins.size();

    }