/**
 * Given a list 'data', a start index 'startIndex', and an end index 'endIndex', this function should return
 * a new list that contains the elements of 'data' from 'startIndex' to 'endIndex' (inclusive) using list slicing.
 *
 * Example:
 * data = listOf(10, 20, 30, 40, 50, 60, 70, 80, 90)
 * startIndex = 2
 * endIndex = 6
 *
 * The function should return:
 * [30, 40, 50, 60, 70]
 */
fun extractData(data: List<Int>, startIndex: Int, endIndex: Int): List<Int> {

    // Initialize an empty list to store the extracted data
    val extractedData = mutableListOf<Int>()

    // Ensure that the startIndex and endIndex are within the boundaries of the list
    val start = if (startIndex < 0) 0 else startIndex
    val end = if (endIndex >= data.size) data.size - 1 else endIndex

    // Perform list slicing using the given startIndex and endIndex
    extractedData.addAll(data.subList(start, end + 1))

    return extractedData
}
/**
 * Given a list 'data', a start index 'startIndex', and an end index 'endIndex', this function should return
 * a new list that contains the elements of 'data' from 'startIndex' to 'endIndex' (inclusive) using list slicing.
 *
 * Example:
 * data = listOf(10, 20, 30, 40, 50, 60, 70, 80, 90)
 * startIndex = 2
 * endIndex = 6
 *
 * The function should return:
 * [30, 40, 50, 60, 70]
 */
fun extractData(data: List<Int>, startIndex: Int, endIndex: Int): List<Int> {
/**
 * Given a list 'data', a start index 'startIndex', and an end index 'endIndex', this function should return
 * a new list that contains the elements of 'data' from 'startIndex' to 'endIndex' (inclusive) using list slicing.
 *
 * Example:
 * data = listOf(10, 20, 30, 40, 50, 60, 70, 80, 90)
 * startIndex = 2
 * endIndex = 6
 *
 * The function should return:
 * [30, 40, 50, 60, 70]
 */
fun extractData(data: List<Int>, startIndex: Int, endIndex: Int): List<Int> {

    // Initialize an empty list to store the extracted data
    val extractedData = mutableListOf<Int>()

    // Ensure that the startIndex and endIndex are within the boundaries of the list
    val start = if (startIndex < 0) 0 else startIndex
    val end = if (endIndex >= data.size) data.size - 1 else endIndex

    // Perform list slicing using the given startIndex and endIndex
    extractedData.addAll(data.subList(start, end + 1))

    return extractedData
}