Check for index 0 if given value val can be obtained by either adding to or subtracting arr [ 0 ] from num .
if ( ind == 0 ) : NEW_LINE INDENT if ( num - arr [ ind ] == val or num + arr [ ind ] == val ) : NEW_LINE INDENT dp [ ind ] [ val ] = 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT dp [ ind ] [ val ] = 0 ; NEW_LINE DEDENT DEDENT else : NEW_LINE