Algorithms and Data Structures/Coding Practices

AlgoExpert Move Element to End

brightlightkim 2022. 7. 20. 15:49

def moveElementToEnd(array, toMove):
    tmp = 0
    for i in range(len(array)):
        if array[i] != toMove:
            array[i], array[tmp] = array[tmp], array[i]
            tmp += 1
    return array
저작자표시 (새창열림)