/**
 * This function finds the intersection of dictionary items and list elements.
 *
 * @param dictList A list containing dictionaries as elements.
 * @return A list of common elements found in the dictionaries and lists.
 */
fun findIntersection(dictList: List<Map<String, Any>>): List<Any> {

    val intersection = mutableListOf<Any>()

    // Iterate through each dictionary in the list
    for (dictionary in dictList) {
        // Iterate through each key-value pair in the dictionary
        for ((key, value) in dictionary) {
            // Check if the value is present in any other dictionary in the list
            if (dictList.all { otherDict -> value in otherDict.values && otherDict != dictionary }) {
                // Check if the value is present in any other list element
                if (dictList.all { element -> value in element.values && element != dictionary }) {
                    // Check if the value is not already in the intersection list
                    if (value !in intersection) {
                        intersection.add(value)
                    }
                }
            }
        }
    }

    return intersection
}

// Example usage
val dictList = listOf(
    mapOf("name" to "John", "age" to 25, "country" to "USA"),
    mapOf("name" to "Emma", "age" to 30, "country" to "UK"),
    mapOf("name" to "Maria")
)
/**
 * This function finds the intersection of dictionary items and list elements.
 *
 * @param dictList A list containing dictionaries as elements.
 * @return A list of common elements found in the dictionaries and lists.
 */
fun findIntersection(dictList: List<Map<String, Any>>): List<Any> {
/**
 * This function finds the intersection of dictionary items and list elements.
 *
 * @param dictList A list containing dictionaries as elements.
 * @return A list of common elements found in the dictionaries and lists.
 */
fun findIntersection(dictList: List<Map<String, Any>>): List<Any> {

    val intersection = mutableListOf<Any>()

    // Iterate through each dictionary in the list
    for (dictionary in dictList) {
        // Iterate through each key-value pair in the dictionary
        for ((key, value) in dictionary) {
            // Check if the value is present in any other dictionary in the list
            if (dictList.all { otherDict -> value in otherDict.values && otherDict != dictionary }) {
                // Check if the value is present in any other list element
                if (dictList.all { element -> value in element.values && element != dictionary }) {
                    // Check if the value is not already in the intersection list
                    if (value !in intersection) {
                        intersection.add(value)
                    }
                }
            }
        }
    }

    return intersection
}

// Example usage
val dictList = listOf(
    mapOf("name" to "John", "age" to 25, "country" to "USA"),
    mapOf("name" to "Emma", "age" to 30, "country" to "UK"),
    mapOf("name" to "Maria")
)