from typing import Iterable


def remove_non_extreme_numbers(s: Iterable[str], leave_min=True) -> Iterable[str]:
    """
    Removes from an iterable all numbers which are neither minimal or maximal.
    All non-numeric elements are left untouched.
    The order of elements might be different in the output.

    Example: ['3', '6', 'N', '7'] -> ['N', '3', '7']
    :param s: Iterable of expressions as strings
    :param leave_min: If set to True, preserve minimal and maximum value from s. Otherwise, only maximum is preserved.
    :return: Transformed iterable
    """
    max_num = float('-inf')
    min_num = 0
    res = []

    for el in s:
        if type(el) is str and el.isdecimal():
            el_num = int(el)
            min_num = min(min_num, el_num)
            max_num = max(max_num, el_num)
        elif el is not None:
            res.append(el)

    if max_num > 0:
        res.append(str(max_num))
    if leave_min and min_num > 0 and min_num != max_num:
        res.append(str(min_num))

    return res