count_number_of_inversions.py
def merge_and_count(first, second):
    """
    It is explained during lecture that while implementing merge part there is a single path that
    counts the inversions automatically if the second part of the

    """
    i = 0
    j = 0
    ret = []
    number_of_inversion = 0
    while len(ret) != len(first) + len(second):
        if i == len(first):
            ret += second[j:]
        elif j == len(second):
            ret += first[i:]
        else:
            if first[i] < second[j]:
                ret.append(first[i])
                i += 1
            else:
                ret.append(second[j])
                j += 1
                number_of_inversion += len(first) - i
    return ret,number_of_inversion

    It is explained during lecture that while implementing merge part there is a single path that
    counts the inversions automatically if the second part of the

    
It is explained during lecture that while implementing merge part there is a single path that
counts the inversions automatically if the second part of the
It is explained during lecture that while implementing merge part there is a single path that counts the inversions automatically if the second part of the
def merge_and_count(first, second):
    i = 0
    j = 0
    ret = []
    number_of_inversion = 0
    while len(ret) != len(first) + len(second):
        if i == len(first):
            ret += second[j:]
        elif j == len(second):
            ret += first[i:]
        else:
            if first[i] < second[j]:
                ret.append(first[i])
                i += 1
            else:
                ret.append(second[j])
                j += 1
                number_of_inversion += len(first) - i
    return ret,number_of_inversion
def merge_and_count ( first , second ) : i = 0 j = 0 ret = [ ] number_of_inversion = 0 while len ( ret ) != len ( first ) + len ( second ) : if i == len ( first ) : ret += second [ j : ] elif j == len ( second ) : ret += first [ i : ] else : if first [ i ] < second [ j ] : ret . append ( first [ i ] ) i += 1 else : ret . append ( second [ j ] ) j += 1 number_of_inversion += len ( first ) - i return ret , number_of_inversion
It is explained during lecture that while implementing merge part there is a single path that
counts the inversions automatically if the second part of the
It is explained during lecture that while implementing merge part there is a single path that counts the inversions automatically if the second part of the
"""
    It is explained during lecture that while implementing merge part there is a single path that
    counts the inversions automatically if the second part of the

    """
first
second