def next_greater_digit_index(digits: list, i: int) -> int:
    """
    Find the next greater digit in the right portion of
    number[i] - that is from digit at index i+1 to last
    digit. Let that digit be number[j] at index 'j'.

    :param digits: list of digits
    :param i: index of number[i]
    :return: next greater digit in the right portion of number[i]
    """
    j: int = -1
    current = ''
    if len(digits[i:]) == 1 and digits[1] > digits[0]:
        return i
    else:
        for index, digit in enumerate(digits[i:]):
            if digits[i - 1] < digit:
                if current == '':
                    current = digit
                    j = i + index
                elif current > digit:
                    current = digit
                    j = i + index
    return j