/**
 * Given a sentence and a list of indices, returns the words at the specified indices in the sentence.
 *
 * @param sentence The input sentence.
 * @param indexList A list of indices.
 * @return A list of words at the specified indices in the sentence.
 */
fun findWordsByIndex(sentence: String, indexList: List<Int>): List<String> {

    // Split the sentence into words
    val words = sentence.split(" ")

    // Create an empty list to store the selected words
    val selectedWords = mutableListOf<String>()

    // Loop through each index in the index list
    for (index in indexList) {
        // Check if the index is valid (within the range of words list)
        if (index >= 0 && index < words.size) {
            // Add the word at the specified index to the selectedWords list
            selectedWords.add(words[index])
        }
    }

    return selectedWords
}
/**
 * Given a sentence and a list of indices, returns the words at the specified indices in the sentence.
 *
 * @param sentence The input sentence.
 * @param indexList A list of indices.
 * @return A list of words at the specified indices in the sentence.
 */
fun findWordsByIndex(sentence: String, indexList: List<Int>): List<String> {
/**
 * Given a sentence and a list of indices, returns the words at the specified indices in the sentence.
 *
 * @param sentence The input sentence.
 * @param indexList A list of indices.
 * @return A list of words at the specified indices in the sentence.
 */
fun findWordsByIndex(sentence: String, indexList: List<Int>): List<String> {

    // Split the sentence into words
    val words = sentence.split(" ")

    // Create an empty list to store the selected words
    val selectedWords = mutableListOf<String>()

    // Loop through each index in the index list
    for (index in indexList) {
        // Check if the index is valid (within the range of words list)
        if (index >= 0 && index < words.size) {
            // Add the word at the specified index to the selectedWords list
            selectedWords.add(words[index])
        }
    }

    return selectedWords
}