/**
 * Given a list, modify the elements at the specified range with a new value.
 *
 * @param data The list of elements.
 * @param startIndex The starting index of the range.
 * @param endIndex The ending index of the range (exclusive).
 * @param newValue The new value to assign.
 * @return The modified list.
 *
 * Example:
 * modifyElements(listOf(1, 2, 3, 4, 5), 1, 4, "x") returns [1, "x", "x", "x", 5]
 */
fun modifyElements(data: MutableList<Any>, startIndex: Int, endIndex: Int, newValue: Any): List<Any> {

    // Use subList and fill to modify the elements in the given range
    data.subList(startIndex, endIndex).fill(newValue)
    return data
}
/**
 * Given a list, modify the elements at the specified range with a new value.
 *
 * @param data The list of elements.
 * @param startIndex The starting index of the range.
 * @param endIndex The ending index of the range (exclusive).
 * @param newValue The new value to assign.
 * @return The modified list.
 *
 * Example:
 * modifyElements(listOf(1, 2, 3, 4, 5), 1, 4, "x") returns [1, "x", "x", "x", 5]
 */
fun modifyElements(data: MutableList<Any>, startIndex: Int, endIndex: Int, newValue: Any): List<Any> {
/**
 * Given a list, modify the elements at the specified range with a new value.
 *
 * @param data The list of elements.
 * @param startIndex The starting index of the range.
 * @param endIndex The ending index of the range (exclusive).
 * @param newValue The new value to assign.
 * @return The modified list.
 *
 * Example:
 * modifyElements(listOf(1, 2, 3, 4, 5), 1, 4, "x") returns [1, "x", "x", "x", 5]
 */
fun modifyElements(data: MutableList<Any>, startIndex: Int, endIndex: Int, newValue: Any): List<Any> {

    // Use subList and fill to modify the elements in the given range
    data.subList(startIndex, endIndex).fill(newValue)
    return data
}