/**
 * Given a list [lst], replace the elements from index [start] to index [end] (inclusive)
 * with the elements in the list [newElements]. Return the modified list.
 *
 * @param lst The original list.
 * @param start The index where the replacement should start.
 * @param end The index where the replacement should end (inclusive).
 * @param newElements The list of new elements to replace the original elements.
 * @return The modified list with replaced elements.
 */
fun replaceElements(lst: MutableList<Any>, start: Int, end: Int, newElements: List<Any>): MutableList<Any> {

    // Slicing the original list to get the prefix and suffix
    val prefix = lst.subList(0, start)
    val suffix = lst.subList(end + 1, lst.size)
    
    // Creating a new list by concatenating the prefix, newElements, and suffix
    val newLst = ArrayList(prefix + newElements + suffix)
    
    return newLst
}
/**
 * Given a list [lst], replace the elements from index [start] to index [end] (inclusive)
 * with the elements in the list [newElements]. Return the modified list.
 *
 * @param lst The original list.
 * @param start The index where the replacement should start.
 * @param end The index where the replacement should end (inclusive).
 * @param newElements The list of new elements to replace the original elements.
 * @return The modified list with replaced elements.
 */
fun replaceElements(lst: MutableList<Any>, start: Int, end: Int, newElements: List<Any>): MutableList<Any> {
/**
 * Given a list [lst], replace the elements from index [start] to index [end] (inclusive)
 * with the elements in the list [newElements]. Return the modified list.
 *
 * @param lst The original list.
 * @param start The index where the replacement should start.
 * @param end The index where the replacement should end (inclusive).
 * @param newElements The list of new elements to replace the original elements.
 * @return The modified list with replaced elements.
 */
fun replaceElements(lst: MutableList<Any>, start: Int, end: Int, newElements: List<Any>): MutableList<Any> {

    // Slicing the original list to get the prefix and suffix
    val prefix = lst.subList(0, start)
    val suffix = lst.subList(end + 1, lst.size)
    
    // Creating a new list by concatenating the prefix, newElements, and suffix
    val newLst = ArrayList(prefix + newElements + suffix)
    
    return newLst
}