if it crosses the right index of query or end of set , then break
if it == len ( s ) or s [ it ] > que [ i ] . r : NEW_LINE INDENT break NEW_LINE DEDENT que [ i ] . l = s [ it ] NEW_LINE val = arr [ s [ it ] ] + 1 NEW_LINE