public static boolean subsetSum(int n, int curIndex, int sum, int[] set)
    {
        if(n == 0)
            return true;
        if(set.length-1 < curIndex)
            return false;
        if(sum + set[curIndex] == n)
            return true;

        return subsetSum(n, curIndex + 1, sum + set[curIndex], set) ||
                       subsetSum(n, curIndex + 1, sum, set);
    }