```
class Solution(object):
def findTargetSumWays(self, nums, S):
"""
:type nums: List[int]
:type S: int
:rtype: int
"""
dic = {0:1}
for n in nums:
newDic = {}
for key, val in dic.iteritems():
newDic[key+n] = newDic.get(key+n, 0) + val
newDic[key-n] = newDic.get(key-n, 0) + val
dic = newDic
return dic.get(S, 0)
```