Calculate left and right pointer index .
left = min ( left , where [ i ] ) NEW_LINE right = max ( right , where [ i ] ) NEW_LINE diff = right - left NEW_LINE if ( diff == 0 or diff == 1 ) : NEW_LINE INDENT continue NEW_LINE DEDENT val1 = v [ left ] NEW_LINE val2 = v [ right ] NEW_LINE minn = min ( val1 , val2 ) NEW_LINE