/**
 * Given two dictionaries, find the intersection of keys present in both dictionaries and return a new dictionary.
 * The value for each key in the new dictionary should be the sum of values for the same key in both dictionaries.
 *
 * @param dictionary1 The first dictionary.
 * @param dictionary2 The second dictionary.
 * @return A dictionary containing the intersection of keys present in both dictionaries with their corresponding sum of values.
 */
fun findCounts(dictionary1: Map<String, Int>, dictionary2: Map<String, Int>): Map<String, Int> {

    // Use set intersection to find common keys in both dictionaries
    val commonKeys = dictionary1.keys.intersect(dictionary2.keys)

    // Create an empty dictionary to store the intersection of keys and sum of values
    val intersection = mutableMapOf<String, Int>()

    // Iterate over the common keys and calculate the sum of values for each key
    for (key in commonKeys) {
        if (dictionary1.containsKey(key) && dictionary2.containsKey(key)) {
            intersection[key] = dictionary1.getValue(key) + dictionary2.getValue(key)
        }
    }

    return intersection
}
/**
 * Given two dictionaries, find the intersection of keys present in both dictionaries and return a new dictionary.
 * The value for each key in the new dictionary should be the sum of values for the same key in both dictionaries.
 *
 * @param dictionary1 The first dictionary.
 * @param dictionary2 The second dictionary.
 * @return A dictionary containing the intersection of keys present in both dictionaries with their corresponding sum of values.
 */
fun findCounts(dictionary1: Map<String, Int>, dictionary2: Map<String, Int>): Map<String, Int> {
/**
 * Given two dictionaries, find the intersection of keys present in both dictionaries and return a new dictionary.
 * The value for each key in the new dictionary should be the sum of values for the same key in both dictionaries.
 *
 * @param dictionary1 The first dictionary.
 * @param dictionary2 The second dictionary.
 * @return A dictionary containing the intersection of keys present in both dictionaries with their corresponding sum of values.
 */
fun findCounts(dictionary1: Map<String, Int>, dictionary2: Map<String, Int>): Map<String, Int> {

    // Use set intersection to find common keys in both dictionaries
    val commonKeys = dictionary1.keys.intersect(dictionary2.keys)

    // Create an empty dictionary to store the intersection of keys and sum of values
    val intersection = mutableMapOf<String, Int>()

    // Iterate over the common keys and calculate the sum of values for each key
    for (key in commonKeys) {
        if (dictionary1.containsKey(key) && dictionary2.containsKey(key)) {
            intersection[key] = dictionary1.getValue(key) + dictionary2.getValue(key)
        }
    }

    return intersection
}