Traverse Input string and get the count of digits from count1 and count2 array such that difference b / w digit is 1 & store it int c1 & c2 . And store it in variable c1 and c2
for i in range ( 1 , N - 1 ) : NEW_LINE INDENT if ( Str [ i ] == '9' ) : NEW_LINE INDENT continue NEW_LINE DEDENT c1 = count1 [ i - 1 ] [ ord ( Str [ i ] ) - ord ( '0' ) ] NEW_LINE c2 = count2 [ i + 1 ] [ ord ( Str [ i ] ) - ord ( '0' ) + 1 ] NEW_LINE if ( c2 == 0 ) : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT