/**
 * You are working as a nurse and you need to modify a list of names using list methods and slicing.
 *
 * Complete the function to remove the names at the specified index, and insert the new names at that position.
 *
 * @param namesList The original list of names.
 * @param index The index at which the modification needs to be performed.
 * @param newNames The list of new names to be inserted at the specified index.
 * @return The modified list with the new names inserted.
 *
 * Example:
 * namesList = ["Alice", "Bob", "Charlie", "David"]
 * index = 2
 * newNames = ["Emily", "Frank"]
 * modifyList(namesList, index, newNames) => ["Alice", "Bob", "Emily", "Frank", "David"]
 */
fun modifyList(namesList: MutableList<String>, index: Int, newNames: List<String>): List<String> {

    // Remove the names at the specified index
    namesList.subList(index, index + 1).clear()

    // Insert the new names at the specified index
    namesList.addAll(index, newNames)

    return namesList
}
/**
 * You are working as a nurse and you need to modify a list of names using list methods and slicing.
 *
 * Complete the function to remove the names at the specified index, and insert the new names at that position.
 *
 * @param namesList The original list of names.
 * @param index The index at which the modification needs to be performed.
 * @param newNames The list of new names to be inserted at the specified index.
 * @return The modified list with the new names inserted.
 *
 * Example:
 * namesList = ["Alice", "Bob", "Charlie", "David"]
 * index = 2
 * newNames = ["Emily", "Frank"]
 * modifyList(namesList, index, newNames) => ["Alice", "Bob", "Emily", "Frank", "David"]
 */
fun modifyList(namesList: MutableList<String>, index: Int, newNames: List<String>): List<String> {
/**
 * You are working as a nurse and you need to modify a list of names using list methods and slicing.
 *
 * Complete the function to remove the names at the specified index, and insert the new names at that position.
 *
 * @param namesList The original list of names.
 * @param index The index at which the modification needs to be performed.
 * @param newNames The list of new names to be inserted at the specified index.
 * @return The modified list with the new names inserted.
 *
 * Example:
 * namesList = ["Alice", "Bob", "Charlie", "David"]
 * index = 2
 * newNames = ["Emily", "Frank"]
 * modifyList(namesList, index, newNames) => ["Alice", "Bob", "Emily", "Frank", "David"]
 */
fun modifyList(namesList: MutableList<String>, index: Int, newNames: List<String>): List<String> {

    // Remove the names at the specified index
    namesList.subList(index, index + 1).clear()

    // Insert the new names at the specified index
    namesList.addAll(index, newNames)

    return namesList
}