/**
 * Given a sequence and a range of indices (startIndex to endIndex), replace the elements within that range with
 * the given replacement list. Return the modified sequence.
 *
 * @param sequence The original sequence of elements.
 * @param startIndex The index at which the replacement should start.
 * @param endIndex The index at which the replacement should end.
 * @param replacement The list of elements to replace with.
 * @return The modified sequence after replacing the elements within the given range.
 *
 * Example:
 * replaceElements(listOf(1, 2, 3, 4, 5), 1, 3, listOf(9, 8, 7))
 * Output: [1, 9, 8, 7, 5]
 */
fun replaceElements(sequence: List<Int>, startIndex: Int, endIndex: Int, replacement: List<Int>): List<Int> {

    return sequence.subList(0, startIndex) + replacement + sequence.subList(endIndex + 1, sequence.size)
}
/**
 * Given a sequence and a range of indices (startIndex to endIndex), replace the elements within that range with
 * the given replacement list. Return the modified sequence.
 *
 * @param sequence The original sequence of elements.
 * @param startIndex The index at which the replacement should start.
 * @param endIndex The index at which the replacement should end.
 * @param replacement The list of elements to replace with.
 * @return The modified sequence after replacing the elements within the given range.
 *
 * Example:
 * replaceElements(listOf(1, 2, 3, 4, 5), 1, 3, listOf(9, 8, 7))
 * Output: [1, 9, 8, 7, 5]
 */
fun replaceElements(sequence: List<Int>, startIndex: Int, endIndex: Int, replacement: List<Int>): List<Int> {
/**
 * Given a sequence and a range of indices (startIndex to endIndex), replace the elements within that range with
 * the given replacement list. Return the modified sequence.
 *
 * @param sequence The original sequence of elements.
 * @param startIndex The index at which the replacement should start.
 * @param endIndex The index at which the replacement should end.
 * @param replacement The list of elements to replace with.
 * @return The modified sequence after replacing the elements within the given range.
 *
 * Example:
 * replaceElements(listOf(1, 2, 3, 4, 5), 1, 3, listOf(9, 8, 7))
 * Output: [1, 9, 8, 7, 5]
 */
fun replaceElements(sequence: List<Int>, startIndex: Int, endIndex: Int, replacement: List<Int>): List<Int> {

    return sequence.subList(0, startIndex) + replacement + sequence.subList(endIndex + 1, sequence.size)
}