/**
 * Given a number line representation and elements to be appended and removed,
 * compute the final number line representation after performing the operations.
 *
 * @param numLine A list representing the number line.
 * @param elements A map containing the elements to append and remove.
 * @return The updated number line representation.
 *
 * Example:
 * computeIntersection(listOf(1, 2, 3, 4, 5), mapOf("append" to listOf(2, 6), "remove" to listOf(3)))
 * Output: [1, 2, 4, 5, 6]
 */
fun computeIntersection(numLine: MutableList<Int>, elements: Map<String, List<Int>>): List<Int> {

    elements["append"]?.forEach { el ->
        if (el !in numLine) {
            numLine.add(el)
        }
    }

    elements["remove"]?.forEach { el ->
        if (el in numLine) {
            numLine.remove(el)
        }
    }

    numLine.sort()
    return numLine
}
/**
 * Given a number line representation and elements to be appended and removed,
 * compute the final number line representation after performing the operations.
 *
 * @param numLine A list representing the number line.
 * @param elements A map containing the elements to append and remove.
 * @return The updated number line representation.
 *
 * Example:
 * computeIntersection(listOf(1, 2, 3, 4, 5), mapOf("append" to listOf(2, 6), "remove" to listOf(3)))
 * Output: [1, 2, 4, 5, 6]
 */
fun computeIntersection(numLine: MutableList<Int>, elements: Map<String, List<Int>>): List<Int> {
/**
 * Given a number line representation and elements to be appended and removed,
 * compute the final number line representation after performing the operations.
 *
 * @param numLine A list representing the number line.
 * @param elements A map containing the elements to append and remove.
 * @return The updated number line representation.
 *
 * Example:
 * computeIntersection(listOf(1, 2, 3, 4, 5), mapOf("append" to listOf(2, 6), "remove" to listOf(3)))
 * Output: [1, 2, 4, 5, 6]
 */
fun computeIntersection(numLine: MutableList<Int>, elements: Map<String, List<Int>>): List<Int> {

    elements["append"]?.forEach { el ->
        if (el !in numLine) {
            numLine.add(el)
        }
    }

    elements["remove"]?.forEach { el ->
        if (el in numLine) {
            numLine.remove(el)
        }
    }

    numLine.sort()
    return numLine
}