/**
 * Given two strings, find the characters that are common to both strings using loops.
 *
 * @param str1 The first string.
 * @param str2 The second string.
 * @return A list containing the common characters found in both strings.
 *
 * Example:
 * findCommonCharacters("economist", "difficult") // ['i', 'c', 'u', 'l', 't']
 * findCommonCharacters("python", "exercise") // ['e']
 */
fun findCommonCharacters(str1: String, str2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    for (char1 in str1) {
        for (char2 in str2) {
            if (char1 == char2) {
                commonChars.add(char1)
            }
        }
    }
    return commonChars
}
/**
 * Given two strings, find the characters that are common to both strings using loops.
 *
 * @param str1 The first string.
 * @param str2 The second string.
 * @return A list containing the common characters found in both strings.
 *
 * Example:
 * findCommonCharacters("economist", "difficult") // ['i', 'c', 'u', 'l', 't']
 * findCommonCharacters("python", "exercise") // ['e']
 */
fun findCommonCharacters(str1: String, str2: String): List<Char> {
/**
 * Given two strings, find the characters that are common to both strings using loops.
 *
 * @param str1 The first string.
 * @param str2 The second string.
 * @return A list containing the common characters found in both strings.
 *
 * Example:
 * findCommonCharacters("economist", "difficult") // ['i', 'c', 'u', 'l', 't']
 * findCommonCharacters("python", "exercise") // ['e']
 */
fun findCommonCharacters(str1: String, str2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    for (char1 in str1) {
        for (char2 in str2) {
            if (char1 == char2) {
                commonChars.add(char1)
            }
        }
    }
    return commonChars
}