HTMLify

Remove All Target from array with O(n)
Views: 142 | Author: abh
def remove_target(target, array):
    array = array.copy()
    ofset = 0
    for i in range(len(array)):
        if array[i] != target:
            array[ofset] = array[i]
            ofset += 1
        if i + ofset >= len(array)-1:
            array[i] = None
    return array

Comments