/**
 * This function modifies a list by replacing a slice of elements with new elements.
 *
 * @param someList The original list to be modified
 * @param startIndex The starting index of the slice to be replaced
 * @param endIndex The ending index (exclusive) of the slice to be replaced
 * @param newElements The list of new elements to be inserted in the slice
 * @return The modified list
 *
 * Example:
 * modifyList(mutableListOf(1, 2, 3, 4, 5), 1, 4, listOf(7, 8, 9))
 * Output: [1, 7, 8, 9, 5]
 */
fun modifyList(someList: MutableList<Int>, startIndex: Int, endIndex: Int, newElements: List<Int>): List<Int> {

    // Remove the slice of elements
    someList.subList(startIndex, endIndex).clear()

    // Concatenate new elements at the start index
    someList.addAll(startIndex, newElements)

    return someList
}
/**
 * This function modifies a list by replacing a slice of elements with new elements.
 *
 * @param someList The original list to be modified
 * @param startIndex The starting index of the slice to be replaced
 * @param endIndex The ending index (exclusive) of the slice to be replaced
 * @param newElements The list of new elements to be inserted in the slice
 * @return The modified list
 *
 * Example:
 * modifyList(mutableListOf(1, 2, 3, 4, 5), 1, 4, listOf(7, 8, 9))
 * Output: [1, 7, 8, 9, 5]
 */
fun modifyList(someList: MutableList<Int>, startIndex: Int, endIndex: Int, newElements: List<Int>): List<Int> {
/**
 * This function modifies a list by replacing a slice of elements with new elements.
 *
 * @param someList The original list to be modified
 * @param startIndex The starting index of the slice to be replaced
 * @param endIndex The ending index (exclusive) of the slice to be replaced
 * @param newElements The list of new elements to be inserted in the slice
 * @return The modified list
 *
 * Example:
 * modifyList(mutableListOf(1, 2, 3, 4, 5), 1, 4, listOf(7, 8, 9))
 * Output: [1, 7, 8, 9, 5]
 */
fun modifyList(someList: MutableList<Int>, startIndex: Int, endIndex: Int, newElements: List<Int>): List<Int> {

    // Remove the slice of elements
    someList.subList(startIndex, endIndex).clear()

    // Concatenate new elements at the start index
    someList.addAll(startIndex, newElements)

    return someList
}