/**
 * This function takes in two arrays and deletes the common elements in both arrays using if statement.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return The modified array1 after deleting the common elements.
 *
 * Example:
 * deleteElementsIfStatement(arrayOf(1, 2, 3, 4, 5), arrayOf(4, 5, 6, 7, 8)) // [1, 2, 3]
 */
fun deleteElementsIfStatement(array1: MutableList<Int>, array2: List<Int>): List<Int> {

    val iterator = array1.iterator()
    while (iterator.hasNext()) {
        val elem = iterator.next()
        if (elem in array2) {
            iterator.remove()
        }
    }
    return array1
}
/**
 * This function takes in two arrays and deletes the common elements in both arrays using if statement.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return The modified array1 after deleting the common elements.
 *
 * Example:
 * deleteElementsIfStatement(arrayOf(1, 2, 3, 4, 5), arrayOf(4, 5, 6, 7, 8)) // [1, 2, 3]
 */
fun deleteElementsIfStatement(array1: MutableList<Int>, array2: List<Int>): List<Int> {
/**
 * This function takes in two arrays and deletes the common elements in both arrays using if statement.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return The modified array1 after deleting the common elements.
 *
 * Example:
 * deleteElementsIfStatement(arrayOf(1, 2, 3, 4, 5), arrayOf(4, 5, 6, 7, 8)) // [1, 2, 3]
 */
fun deleteElementsIfStatement(array1: MutableList<Int>, array2: List<Int>): List<Int> {

    val iterator = array1.iterator()
    while (iterator.hasNext()) {
        val elem = iterator.next()
        if (elem in array2) {
            iterator.remove()
        }
    }
    return array1
}