/**
 * Given a list of strings, find the characters that are common to all strings and return them.
 *
 * @param strList A list of strings.
 * @return A string containing the characters that are common to all strings.
 *
 * Example:
 * findCommonChars(listOf("hello", "world")) // Returns "l"
 * findCommonChars(listOf("apple", "banana")) // Returns "a"
 * findCommonChars(listOf("abcd", "efgh", "ijkl")) // Returns ""
 */
fun findCommonChars(strList: List<String>): String {

    // Initialize a set of all characters in the first string
    var commonChars = strList[0].toSet()

    // Iterate through each character of the first string
    for (char in strList[0]) {
        // Check if the character exists in all other strings
        for (string in strList.subList(1, strList.size)) {
            if (char !in string) {
                // If the character does not exist in any of the other strings, remove it from commonChars set
                commonChars = commonChars.minus(char)
                break
            }
        }
    }

    // Return the sorted string of common characters
    return commonChars.sorted().joinToString("")
}
/**
 * Given a list of strings, find the characters that are common to all strings and return them.
 *
 * @param strList A list of strings.
 * @return A string containing the characters that are common to all strings.
 *
 * Example:
 * findCommonChars(listOf("hello", "world")) // Returns "l"
 * findCommonChars(listOf("apple", "banana")) // Returns "a"
 * findCommonChars(listOf("abcd", "efgh", "ijkl")) // Returns ""
 */
fun findCommonChars(strList: List<String>): String {
/**
 * Given a list of strings, find the characters that are common to all strings and return them.
 *
 * @param strList A list of strings.
 * @return A string containing the characters that are common to all strings.
 *
 * Example:
 * findCommonChars(listOf("hello", "world")) // Returns "l"
 * findCommonChars(listOf("apple", "banana")) // Returns "a"
 * findCommonChars(listOf("abcd", "efgh", "ijkl")) // Returns ""
 */
fun findCommonChars(strList: List<String>): String {

    // Initialize a set of all characters in the first string
    var commonChars = strList[0].toSet()

    // Iterate through each character of the first string
    for (char in strList[0]) {
        // Check if the character exists in all other strings
        for (string in strList.subList(1, strList.size)) {
            if (char !in string) {
                // If the character does not exist in any of the other strings, remove it from commonChars set
                commonChars = commonChars.minus(char)
                break
            }
        }
    }

    // Return the sorted string of common characters
    return commonChars.sorted().joinToString("")
}