/**
 * This function takes in an existing list and a list of elements to add. It removes any duplicates from the existing list
 * and appends only the elements that are not already present in the existing list. The updated list is returned.
 */
fun removeDuplicatesAndAddElementsNotInList(existingList: MutableList<Int>, elementsToAdd: List<Int>): List<Int> {

    // Remove duplicates from existing list
    existingList.removeAll { it in existingList }

    // Append elements that are not already present in the existing list
    for (element in elementsToAdd) {
        if (element !in existingList) {
            existingList.add(element)
        }
    }

    return existingList
}

// Example usage
/**
 * This function takes in an existing list and a list of elements to add. It removes any duplicates from the existing list
 * and appends only the elements that are not already present in the existing list. The updated list is returned.
 */
fun removeDuplicatesAndAddElementsNotInList(existingList: MutableList<Int>, elementsToAdd: List<Int>): List<Int> {
/**
 * This function takes in an existing list and a list of elements to add. It removes any duplicates from the existing list
 * and appends only the elements that are not already present in the existing list. The updated list is returned.
 */
fun removeDuplicatesAndAddElementsNotInList(existingList: MutableList<Int>, elementsToAdd: List<Int>): List<Int> {

    // Remove duplicates from existing list
    existingList.removeAll { it in existingList }

    // Append elements that are not already present in the existing list
    for (element in elementsToAdd) {
        if (element !in existingList) {
            existingList.add(element)
        }
    }

    return existingList
}

// Example usage