/**
 * Given a list of artist names, find the common letters in the names.
 * Return a Pair containing the common letters and the number of times they appear.
 *
 * Example:
 * findCommonLetters(listOf("Van Gogh", "Picasso", "Monet", "Banksy")) -> Pair('o', 2)
 *
 * Explanation:
 * The common letter 'o' appears twice in the names 'Monet' and 'Picasso'.
 */
fun findCommonLetters(artistNames: List<String>): Pair<Char, Int> {

    var commonLetters = artistNames[0].toSet()
    for (name in artistNames.drop(1)) {
        commonLetters = commonLetters.intersect(name.toSet())
    }

    var commonLetterCount = 0
    var mostCommonLetter = ' '
    for (letter in commonLetters) {
        val letterCount = artistNames.sumBy { it.count { it == letter } }
        if (letterCount > commonLetterCount) {
            commonLetterCount = letterCount
            mostCommonLetter = letter
        }
    }

    return Pair(mostCommonLetter, commonLetterCount)
}
/**
 * Given a list of artist names, find the common letters in the names.
 * Return a Pair containing the common letters and the number of times they appear.
 *
 * Example:
 * findCommonLetters(listOf("Van Gogh", "Picasso", "Monet", "Banksy")) -> Pair('o', 2)
 *
 * Explanation:
 * The common letter 'o' appears twice in the names 'Monet' and 'Picasso'.
 */
fun findCommonLetters(artistNames: List<String>): Pair<Char, Int> {
/**
 * Given a list of artist names, find the common letters in the names.
 * Return a Pair containing the common letters and the number of times they appear.
 *
 * Example:
 * findCommonLetters(listOf("Van Gogh", "Picasso", "Monet", "Banksy")) -> Pair('o', 2)
 *
 * Explanation:
 * The common letter 'o' appears twice in the names 'Monet' and 'Picasso'.
 */
fun findCommonLetters(artistNames: List<String>): Pair<Char, Int> {

    var commonLetters = artistNames[0].toSet()
    for (name in artistNames.drop(1)) {
        commonLetters = commonLetters.intersect(name.toSet())
    }

    var commonLetterCount = 0
    var mostCommonLetter = ' '
    for (letter in commonLetters) {
        val letterCount = artistNames.sumBy { it.count { it == letter } }
        if (letterCount > commonLetterCount) {
            commonLetterCount = letterCount
            mostCommonLetter = letter
        }
    }

    return Pair(mostCommonLetter, commonLetterCount)
}