/**
 * This function replaces words in a sentence based on the given replacements.
 *
 * @param words list of words in a sentence
 * @param replacements dictionary containing words to be replaced as keys and their corresponding replacements as values
 * @return modifiedWords list of words with replaced elements
 *
 * Examples:
 * replaceWords(listOf("The", "color", "of", "the", "walls", "is", "yellow"), mapOf("color" to "shade", "yellow" to "cream"))
 * Output: ['The', 'shade', 'of', 'the', 'walls', 'is', 'cream']
 */
fun replaceWords(words: List<String>, replacements: Map<String, String>): List<String> {

    val modifiedWords = mutableListOf<String>()
    for (word in words) {
        if (replacements.containsKey(word)) {
            modifiedWords.add(replacements[word]!!)
        } else {
            modifiedWords.add(word)
        }
    }
    return modifiedWords
}
/**
 * This function replaces words in a sentence based on the given replacements.
 *
 * @param words list of words in a sentence
 * @param replacements dictionary containing words to be replaced as keys and their corresponding replacements as values
 * @return modifiedWords list of words with replaced elements
 *
 * Examples:
 * replaceWords(listOf("The", "color", "of", "the", "walls", "is", "yellow"), mapOf("color" to "shade", "yellow" to "cream"))
 * Output: ['The', 'shade', 'of', 'the', 'walls', 'is', 'cream']
 */
fun replaceWords(words: List<String>, replacements: Map<String, String>): List<String> {
/**
 * This function replaces words in a sentence based on the given replacements.
 *
 * @param words list of words in a sentence
 * @param replacements dictionary containing words to be replaced as keys and their corresponding replacements as values
 * @return modifiedWords list of words with replaced elements
 *
 * Examples:
 * replaceWords(listOf("The", "color", "of", "the", "walls", "is", "yellow"), mapOf("color" to "shade", "yellow" to "cream"))
 * Output: ['The', 'shade', 'of', 'the', 'walls', 'is', 'cream']
 */
fun replaceWords(words: List<String>, replacements: Map<String, String>): List<String> {

    val modifiedWords = mutableListOf<String>()
    for (word in words) {
        if (replacements.containsKey(word)) {
            modifiedWords.add(replacements[word]!!)
        } else {
            modifiedWords.add(word)
        }
    }
    return modifiedWords
}