/**
 * Given two strings, find and return a list of all the common characters between them.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters between the two strings.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonCharacters = mutableListOf<Char>()

    // Extracting unique characters from the first string
    for (char in string1) {
        if (char !in commonCharacters) {
            commonCharacters.add(char)
        }
    }

    // Removing non-common characters from the list
    val iterator = commonCharacters.iterator()
    while (iterator.hasNext()) {
        val char = iterator.next()
        if (char !in string2) {
            iterator.remove()
        }
    }

    return commonCharacters
}
/**
 * Given two strings, find and return a list of all the common characters between them.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters between the two strings.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {
/**
 * Given two strings, find and return a list of all the common characters between them.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters between the two strings.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonCharacters = mutableListOf<Char>()

    // Extracting unique characters from the first string
    for (char in string1) {
        if (char !in commonCharacters) {
            commonCharacters.add(char)
        }
    }

    // Removing non-common characters from the list
    val iterator = commonCharacters.iterator()
    while (iterator.hasNext()) {
        val char = iterator.next()
        if (char !in string2) {
            iterator.remove()
        }
    }

    return commonCharacters
}