/**
 * This exercise aims to remove elements from a list within a specific range using the range function.
 *
 * @param nums a list of integers
 * @param start an integer indicating the starting index (inclusive) for removing elements
 * @param end an integer indicating the ending index (exclusive) for removing elements
 * @return The modified list after removing elements within the given range
 */
fun removeElements(nums: MutableList<Int>, start: Int, end: Int): MutableList<Int> {

    // Checking if the given range is valid
    if (start >= end || start < 0 || end > nums.size) {
        throw IllegalArgumentException("Invalid range!")
    }

    // Removing elements within the given range
    for (i in start until end) {
        nums.removeAt(start)
    }

    return nums
}

// Removing elements from index 2 to 5 (excluding index 5 itself)
val nums = mutableListOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val startIndex = 2
val endIndex = 5
val result = removeElements(nums, startIndex, endIndex)
/**
 * This exercise aims to remove elements from a list within a specific range using the range function.
 *
 * @param nums a list of integers
 * @param start an integer indicating the starting index (inclusive) for removing elements
 * @param end an integer indicating the ending index (exclusive) for removing elements
 * @return The modified list after removing elements within the given range
 */
fun removeElements(nums: MutableList<Int>, start: Int, end: Int): MutableList<Int> {
/**
 * This exercise aims to remove elements from a list within a specific range using the range function.
 *
 * @param nums a list of integers
 * @param start an integer indicating the starting index (inclusive) for removing elements
 * @param end an integer indicating the ending index (exclusive) for removing elements
 * @return The modified list after removing elements within the given range
 */
fun removeElements(nums: MutableList<Int>, start: Int, end: Int): MutableList<Int> {

    // Checking if the given range is valid
    if (start >= end || start < 0 || end > nums.size) {
        throw IllegalArgumentException("Invalid range!")
    }

    // Removing elements within the given range
    for (i in start until end) {
        nums.removeAt(start)
    }

    return nums
}

// Removing elements from index 2 to 5 (excluding index 5 itself)
val nums = mutableListOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val startIndex = 2
val endIndex = 5
val result = removeElements(nums, startIndex, endIndex)