/**
 * Accepts two strings as arguments and returns a list of characters 
 * that are present in both strings, using loops.
 *
 * @param string1 The first input string.
 * @param string2 The second input string.
 * @return A list of characters that are present in both strings.
 *
 * Example:
 * findMatchingCharacters("hello", "world") // ['o', 'l']
 */
fun findMatchingCharacters(string1: String, string2: String): List<Char> {

    val matchingCharacters = mutableListOf<Char>()

    // Loop through each character in string1
    for (char1 in string1) {
        // Loop through each character in string2
        for (char2 in string2) {
            // Check if the character is present in both strings
            if (char1 == char2) {
                // Check if the character is already in the matchingCharacters list
                if (!matchingCharacters.contains(char1)) {
                    matchingCharacters.add(char1)
                }
            }
        }
    }

    return matchingCharacters
}
/**
 * Accepts two strings as arguments and returns a list of characters 
 * that are present in both strings, using loops.
 *
 * @param string1 The first input string.
 * @param string2 The second input string.
 * @return A list of characters that are present in both strings.
 *
 * Example:
 * findMatchingCharacters("hello", "world") // ['o', 'l']
 */
fun findMatchingCharacters(string1: String, string2: String): List<Char> {
/**
 * Accepts two strings as arguments and returns a list of characters 
 * that are present in both strings, using loops.
 *
 * @param string1 The first input string.
 * @param string2 The second input string.
 * @return A list of characters that are present in both strings.
 *
 * Example:
 * findMatchingCharacters("hello", "world") // ['o', 'l']
 */
fun findMatchingCharacters(string1: String, string2: String): List<Char> {

    val matchingCharacters = mutableListOf<Char>()

    // Loop through each character in string1
    for (char1 in string1) {
        // Loop through each character in string2
        for (char2 in string2) {
            // Check if the character is present in both strings
            if (char1 == char2) {
                // Check if the character is already in the matchingCharacters list
                if (!matchingCharacters.contains(char1)) {
                    matchingCharacters.add(char1)
                }
            }
        }
    }

    return matchingCharacters
}