/**
 * You are working as an interior designer and have received two strings that represent
 * the names of different interior design elements. Your task is to find and return a
 * list of common characters present in both strings.
 *
 * For example, if the input strings are "cabinet" and "chair", the common characters
 * are 'a' and 'i', so the output should be ['a', 'i'].
 *
 * Complete the code below to solve this exercise.
 */
fun findCommonCharacters(text1: String, text2: String): List<Char> {

    val commonChars = mutableListOf<Char>()  // List to store the common characters

    // Loops through each character in text1
    for (char1 in text1) {
        // Checks if the character is present in text2 and not in commonChars
        if (char1 in text2 && char1 !in commonChars) {
            commonChars.add(char1)  // Adds the common character to the list
        }
    }

    return commonChars
}
/**
 * You are working as an interior designer and have received two strings that represent
 * the names of different interior design elements. Your task is to find and return a
 * list of common characters present in both strings.
 *
 * For example, if the input strings are "cabinet" and "chair", the common characters
 * are 'a' and 'i', so the output should be ['a', 'i'].
 *
 * Complete the code below to solve this exercise.
 */
fun findCommonCharacters(text1: String, text2: String): List<Char> {
/**
 * You are working as an interior designer and have received two strings that represent
 * the names of different interior design elements. Your task is to find and return a
 * list of common characters present in both strings.
 *
 * For example, if the input strings are "cabinet" and "chair", the common characters
 * are 'a' and 'i', so the output should be ['a', 'i'].
 *
 * Complete the code below to solve this exercise.
 */
fun findCommonCharacters(text1: String, text2: String): List<Char> {

    val commonChars = mutableListOf<Char>()  // List to store the common characters

    // Loops through each character in text1
    for (char1 in text1) {
        // Checks if the character is present in text2 and not in commonChars
        if (char1 in text2 && char1 !in commonChars) {
            commonChars.add(char1)  // Adds the common character to the list
        }
    }

    return commonChars
}