Store the index of current element and its just smaller element in array w [ ]
currElementPos = pos [ a [ curr ] ] NEW_LINE prevElementPos = pos [ a [ curr - 1 ] ] NEW_LINE if ( currElementPos > prevElementPos ) : NEW_LINE INDENT continue NEW_LINE DEDENT