Base Conditions
if ( N == 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( N < 3 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( N == 3 ) : NEW_LINE INDENT cnt = 0 NEW_LINE if abs ( arr [ 0 ] - arr [ 1 ] ) == K : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT if abs ( arr [ 2 ] - arr [ 1 ] ) == K : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT if abs ( arr [ 0 ] - arr [ 2 ] ) == K : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT return cnt NEW_LINE DEDENT