/**
 * This exercise aims to find the common words between two texts.
 * You need to complete the code by using loops and sets to find the common words.
 *
 * @param text1 A list containing words from the first text
 * @param text2 A list containing words from the second text
 * @return A list containing the common words found in both texts
 */
fun findCommonWords(text1: List<String>, text2: List<String>): List<String> {

    // Convert the lists to sets to remove duplicates and make the intersection easier
    val set1 = text1.toSet()
    val set2 = text2.toSet()

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

    // Iterate over each word in the first text
    for (word in set1) {
        // Check if the word exists in the second text
        if (word in set2) {
            // Append the word to the commonWords list
            commonWords.add(word)
        }
    }

    // Return the list of common words
    return commonWords
}
/**
 * This exercise aims to find the common words between two texts.
 * You need to complete the code by using loops and sets to find the common words.
 *
 * @param text1 A list containing words from the first text
 * @param text2 A list containing words from the second text
 * @return A list containing the common words found in both texts
 */
fun findCommonWords(text1: List<String>, text2: List<String>): List<String> {
/**
 * This exercise aims to find the common words between two texts.
 * You need to complete the code by using loops and sets to find the common words.
 *
 * @param text1 A list containing words from the first text
 * @param text2 A list containing words from the second text
 * @return A list containing the common words found in both texts
 */
fun findCommonWords(text1: List<String>, text2: List<String>): List<String> {

    // Convert the lists to sets to remove duplicates and make the intersection easier
    val set1 = text1.toSet()
    val set2 = text2.toSet()

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

    // Iterate over each word in the first text
    for (word in set1) {
        // Check if the word exists in the second text
        if (word in set2) {
            // Append the word to the commonWords list
            commonWords.add(word)
        }
    }

    // Return the list of common words
    return commonWords
}