/**
 * This function receives two strings 'string1' and 'string2' and iterates over each character of 'string1'
 * within a nested loop. It finds the intersection of the characters in 'string1' and 'string2' and
 * returns a list containing these common characters.
 *
 * @param string1 The first string to be iterated over.
 * @param string2 The second string to compare with the characters of 'string1'.
 * @return A list containing the intersection of characters between 'string1' and 'string2'.
 */
fun nestedLoopAndStringIteration(string1: String, string2: String): List<Char> {

    val intersection = mutableListOf<Char>()

    for (char1 in string1) {
        for (char2 in string2) {
            if (char1 == char2) {
                intersection.add(char1)
            }
        }
    }

    return intersection
}
/**
 * This function receives two strings 'string1' and 'string2' and iterates over each character of 'string1'
 * within a nested loop. It finds the intersection of the characters in 'string1' and 'string2' and
 * returns a list containing these common characters.
 *
 * @param string1 The first string to be iterated over.
 * @param string2 The second string to compare with the characters of 'string1'.
 * @return A list containing the intersection of characters between 'string1' and 'string2'.
 */
fun nestedLoopAndStringIteration(string1: String, string2: String): List<Char> {
/**
 * This function receives two strings 'string1' and 'string2' and iterates over each character of 'string1'
 * within a nested loop. It finds the intersection of the characters in 'string1' and 'string2' and
 * returns a list containing these common characters.
 *
 * @param string1 The first string to be iterated over.
 * @param string2 The second string to compare with the characters of 'string1'.
 * @return A list containing the intersection of characters between 'string1' and 'string2'.
 */
fun nestedLoopAndStringIteration(string1: String, string2: String): List<Char> {

    val intersection = mutableListOf<Char>()

    for (char1 in string1) {
        for (char2 in string2) {
            if (char1 == char2) {
                intersection.add(char1)
            }
        }
    }

    return intersection
}