/**
 * Given a list of journalist names and a set of forbidden names, remove all occurrences of the forbidden
 * names from the list. Return the modified list.
 *
 * @param journalists A list of journalist names.
 * @param forbiddenNames A set of names that should be removed from the list.
 * @return The modified list of journalist names after removing the forbidden names.
 *
 * Example:
 * journalists = ['John', 'Alice', 'Robert', 'Eliza', 'David']
 * forbiddenNames = setOf('Alice', 'David')
 * modifyListElements(journalists, forbiddenNames) // Output: ['John', 'Robert', 'Eliza']
 */
fun modifyListElements(journalists: MutableList<String>, forbiddenNames: Set<String>): List<String> {

    val iterator = journalists.iterator()
    while (iterator.hasNext()) {
        val journalist = iterator.next()
        if (journalist in forbiddenNames) {
            iterator.remove()
        }
    }
    return journalists
}
/**
 * Given a list of journalist names and a set of forbidden names, remove all occurrences of the forbidden
 * names from the list. Return the modified list.
 *
 * @param journalists A list of journalist names.
 * @param forbiddenNames A set of names that should be removed from the list.
 * @return The modified list of journalist names after removing the forbidden names.
 *
 * Example:
 * journalists = ['John', 'Alice', 'Robert', 'Eliza', 'David']
 * forbiddenNames = setOf('Alice', 'David')
 * modifyListElements(journalists, forbiddenNames) // Output: ['John', 'Robert', 'Eliza']
 */
fun modifyListElements(journalists: MutableList<String>, forbiddenNames: Set<String>): List<String> {
/**
 * Given a list of journalist names and a set of forbidden names, remove all occurrences of the forbidden
 * names from the list. Return the modified list.
 *
 * @param journalists A list of journalist names.
 * @param forbiddenNames A set of names that should be removed from the list.
 * @return The modified list of journalist names after removing the forbidden names.
 *
 * Example:
 * journalists = ['John', 'Alice', 'Robert', 'Eliza', 'David']
 * forbiddenNames = setOf('Alice', 'David')
 * modifyListElements(journalists, forbiddenNames) // Output: ['John', 'Robert', 'Eliza']
 */
fun modifyListElements(journalists: MutableList<String>, forbiddenNames: Set<String>): List<String> {

    val iterator = journalists.iterator()
    while (iterator.hasNext()) {
        val journalist = iterator.next()
        if (journalist in forbiddenNames) {
            iterator.remove()
        }
    }
    return journalists
}