Check if the value is equal to K at N , if it is then return 1 as this combination is possible . Otherwise return 0.
if ( idx == N - 1 ) : NEW_LINE INDENT if ( val == K ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 0 NEW_LINE DEDENT ans = 0 NEW_LINE