/**
 * Find the intersection of values between two dictionaries using nested loops with sets.
 *
 * @param dic1 The first dictionary.
 * @param dic2 The second dictionary.
 * @return A set containing the intersecting values.
 *
 * Examples:
 * '``
 * val dic1 = mapOf('a' to listOf(1, 2, 3), 'b' to listOf(4, 5))
 * val dic2 = mapOf('c' to listOf(2, 3, 6), 'd' to listOf(1, 2))
 * println(dictionaryIntersection(dic1, dic2)) // Output: [2, 3, 1]
 * '``
 */
fun dictionaryIntersection(dic1: Map<Char, List<Int>>, dic2: Map<Char, List<Int>>): Set<Int> {

    val intersectSet = mutableSetOf<Int>()

    // Iterate over the values of the first dictionary
    for (values1 in dic1.values) {
        // Iterate over the values of the second dictionary
        for (values2 in dic2.values) {
            // Check if there is an intersection between the two sets of values
            if (values1.intersect(values2).isNotEmpty()) {
                // Add intersecting values to the intersectSet
                intersectSet.addAll(values1.intersect(values2))
            }
        }
    }

    return intersectSet
}
/**
 * Find the intersection of values between two dictionaries using nested loops with sets.
 *
 * @param dic1 The first dictionary.
 * @param dic2 The second dictionary.
 * @return A set containing the intersecting values.
 *
 * Examples:
 * '``
 * val dic1 = mapOf('a' to listOf(1, 2, 3), 'b' to listOf(4, 5))
 * val dic2 = mapOf('c' to listOf(2, 3, 6), 'd' to listOf(1, 2))
 * println(dictionaryIntersection(dic1, dic2)) // Output: [2, 3, 1]
 * '``
 */
fun dictionaryIntersection(dic1: Map<Char, List<Int>>, dic2: Map<Char, List<Int>>): Set<Int> {
/**
 * Find the intersection of values between two dictionaries using nested loops with sets.
 *
 * @param dic1 The first dictionary.
 * @param dic2 The second dictionary.
 * @return A set containing the intersecting values.
 *
 * Examples:
 * '``
 * val dic1 = mapOf('a' to listOf(1, 2, 3), 'b' to listOf(4, 5))
 * val dic2 = mapOf('c' to listOf(2, 3, 6), 'd' to listOf(1, 2))
 * println(dictionaryIntersection(dic1, dic2)) // Output: [2, 3, 1]
 * '``
 */
fun dictionaryIntersection(dic1: Map<Char, List<Int>>, dic2: Map<Char, List<Int>>): Set<Int> {

    val intersectSet = mutableSetOf<Int>()

    // Iterate over the values of the first dictionary
    for (values1 in dic1.values) {
        // Iterate over the values of the second dictionary
        for (values2 in dic2.values) {
            // Check if there is an intersection between the two sets of values
            if (values1.intersect(values2).isNotEmpty()) {
                // Add intersecting values to the intersectSet
                intersectSet.addAll(values1.intersect(values2))
            }
        }
    }

    return intersectSet
}