/**
 * This function takes a string and a list of characters as input.
 * It finds the occurrence of each character in the given string using loops and returns a dictionary of counts.
 *
 * @param string The input string.
 * @param characters The list of characters to find in the string.
 * @return A dictionary containing the counts of each character found in the string.
 */
fun findCharsInString(string: String, characters: List<Char>): Map<Char, Int> {

    // Initialize an empty dictionary to store the counts
    val charCounts = mutableMapOf<Char, Int>()

    // Iterate through each character in the list of characters
    for (char in characters) {
        // Initialize the count for the current character to 0
        var count = 0

        // Iterate through each character in the input string
        for (c in string) {
            // If the character matches the current character, increment the count
            if (c == char) {
                count++
            }
        }

        // Add the character and its count to the dictionary
        charCounts[char] = count
    }

    return charCounts
}
/**
 * This function takes a string and a list of characters as input.
 * It finds the occurrence of each character in the given string using loops and returns a dictionary of counts.
 *
 * @param string The input string.
 * @param characters The list of characters to find in the string.
 * @return A dictionary containing the counts of each character found in the string.
 */
fun findCharsInString(string: String, characters: List<Char>): Map<Char, Int> {
/**
 * This function takes a string and a list of characters as input.
 * It finds the occurrence of each character in the given string using loops and returns a dictionary of counts.
 *
 * @param string The input string.
 * @param characters The list of characters to find in the string.
 * @return A dictionary containing the counts of each character found in the string.
 */
fun findCharsInString(string: String, characters: List<Char>): Map<Char, Int> {

    // Initialize an empty dictionary to store the counts
    val charCounts = mutableMapOf<Char, Int>()

    // Iterate through each character in the list of characters
    for (char in characters) {
        // Initialize the count for the current character to 0
        var count = 0

        // Iterate through each character in the input string
        for (c in string) {
            // If the character matches the current character, increment the count
            if (c == char) {
                count++
            }
        }

        // Add the character and its count to the dictionary
        charCounts[char] = count
    }

    return charCounts
}