/**
 * Given two strings, find and return a list of common characters present in both strings.
 *
 * @param string1 The first string
 * @param string2 The second string
 * @return A list containing the common characters found in both strings
 *
 * Example:
 * findCommonCharacters("psychologist", "intersection") -> ['i', 's', 'o', 'l', 'g']
 * findCommonCharacters("patient", "analysis") -> ['a', 'i']
 * findCommonCharacters("therapy", "hypnosis") -> ['h']
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    for (char in string1) {
        if (char in string2) {
            commonChars.add(char)
        }
    }
    return commonChars
}
/**
 * Given two strings, find and return a list of common characters present in both strings.
 *
 * @param string1 The first string
 * @param string2 The second string
 * @return A list containing the common characters found in both strings
 *
 * Example:
 * findCommonCharacters("psychologist", "intersection") -> ['i', 's', 'o', 'l', 'g']
 * findCommonCharacters("patient", "analysis") -> ['a', 'i']
 * findCommonCharacters("therapy", "hypnosis") -> ['h']
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {
/**
 * Given two strings, find and return a list of common characters present in both strings.
 *
 * @param string1 The first string
 * @param string2 The second string
 * @return A list containing the common characters found in both strings
 *
 * Example:
 * findCommonCharacters("psychologist", "intersection") -> ['i', 's', 'o', 'l', 'g']
 * findCommonCharacters("patient", "analysis") -> ['a', 'i']
 * findCommonCharacters("therapy", "hypnosis") -> ['h']
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    for (char in string1) {
        if (char in string2) {
            commonChars.add(char)
        }
    }
    return commonChars
}