Q:

Place arithmetic signs in correct order to get the number

Given a list of numbers, place signs + or - in order to get the
  required number. 
If it's possible then return true, otherwise return false 
[1, 2, 3, 4, 5, 7]; 12 -> true, because 1 + 2 + 3 + 4 - 5 + 7 = 12
[5, 3]; 7 -> false, because 5 + 3 != 7 and 5 - 3 != 7

I came up with the following brute force solution:
public static boolean trueOrNot(int number, List<Integer> numbers) {
        boolean found = false;
        int i = 0;
        while (!found && i < (1 << numbers.size())) {
            int tmpResult = 0;
            for (int j = 0; j < numbers.size(); j++) {
                int num = numbers.get(j);
                if ((i & (1 << j)) > 0) {
                    num = -num;
                }
                tmpResult += num;
            }
            found = tmpResult == number;
            i++;
        }
        return found;
}

Basically, I took for consideration binary representations of numbers 0000, 0001, 0010...2^n and iterate over every bit, thus getting all possible combinations. 0 is a + sign and 1 is - sign. 
Then I calculate temporal result and once it is equal to the sought number I break out from loop.
Time complexity: O(2n)
Space complexity: O(1)
I just wondering is there any more effective solution with the help of Dynamic Programming, for example?
Feedback for the current solution?

A:

Actually after some studying I figured out another optimal way of solving this problem:
public static boolean trueOrNot(int T, ArrayList<Integer> nums) {
    Map<Integer, Map<Integer, Boolean>> cache = new HashMap<>();
    return trueOrNot(nums, T, 0, 0, cache);
}

private static boolean trueOrNot(ArrayList<Integer> nums, int T, int i, int sum, Map<Integer, Map<Integer, Boolean>> cache) {
    if (i == nums.size()) {
        return sum == T;
    }
    if (!cache.containsKey(i)) cache.put(i, new HashMap<>());
    Boolean cached = cache.get(i).get(sum);
    if (cached != null) return cached;
    boolean result =
            trueOrNot(nums, T, i + 1, sum + nums.get(i), cache)
                    || trueOrNot(nums, T, i + 1, sum - nums.get(i), cache);
    cache.get(i).put(sum, result);
    return result;
}

