Check if the required sum can be obtained by adding current element or by subtracting the current index element
ans = ( dfs ( memo , nums , index + 1 , curr_sum + nums [ index ] , S , sum ) + dfs ( memo , nums , index + 1 , curr_sum - nums [ index ] , S , sum ) ) NEW_LINE