/**
 * Given a list of strings and a set of characters, find and return a map containing the number of occurrences
 * of each character from the set in each string. Only count the characters that appear at least once in each string.
 *
 * @param stringList A list of strings.
 * @param characterSet A set of characters.
 * @return A map containing the number of occurrences of each character in each string.
 *         The keys are the characters from the character set, and the values are lists of integers representing
 *         the count of each character in each string.
 */
fun findCommonCharacters(stringList: List<String>, characterSet: Set<Char>): Map<Char, List<Int>> {

    val commonCharacters = mutableMapOf<Char, List<Int>>()

    for (char in characterSet) {
        val charCountList = mutableListOf<Int>()
        for (string in stringList) {
            var charCount = 0
            for (ch in string) {
                if (ch == char) {
                    charCount++
                }
            }
            charCountList.add(charCount)
        }

        if (charCountList.minOrNull()!! > 0) {
            commonCharacters[char] = charCountList
        }
    }

    return commonCharacters
}
/**
 * Given a list of strings and a set of characters, find and return a map containing the number of occurrences
 * of each character from the set in each string. Only count the characters that appear at least once in each string.
 *
 * @param stringList A list of strings.
 * @param characterSet A set of characters.
 * @return A map containing the number of occurrences of each character in each string.
 *         The keys are the characters from the character set, and the values are lists of integers representing
 *         the count of each character in each string.
 */
fun findCommonCharacters(stringList: List<String>, characterSet: Set<Char>): Map<Char, List<Int>> {
/**
 * Given a list of strings and a set of characters, find and return a map containing the number of occurrences
 * of each character from the set in each string. Only count the characters that appear at least once in each string.
 *
 * @param stringList A list of strings.
 * @param characterSet A set of characters.
 * @return A map containing the number of occurrences of each character in each string.
 *         The keys are the characters from the character set, and the values are lists of integers representing
 *         the count of each character in each string.
 */
fun findCommonCharacters(stringList: List<String>, characterSet: Set<Char>): Map<Char, List<Int>> {

    val commonCharacters = mutableMapOf<Char, List<Int>>()

    for (char in characterSet) {
        val charCountList = mutableListOf<Int>()
        for (string in stringList) {
            var charCount = 0
            for (ch in string) {
                if (ch == char) {
                    charCount++
                }
            }
            charCountList.add(charCount)
        }

        if (charCountList.minOrNull()!! > 0) {
            commonCharacters[char] = charCountList
        }
    }

    return commonCharacters
}