/**
 * Given two lists of tuples, find the common elements between them.
 *
 * @param list1 The first list of tuples.
 * @param list2 The second list of tuples.
 * @return A list of common elements.
 *
 * Example:
 * val list1 = listOf(Pair("apple", 5), Pair("orange", 8), Pair("banana", 4))
 * val list2 = listOf(Pair("apple", 5), Pair("grapes", 2), Pair("banana", 9))
 * findCommonElements(list1, list2)
 * Output: [("apple", 5)]
 */
fun findCommonElements(list1: List<Pair<String, Int>>, list2: List<Pair<String, Int>>): List<Pair<String, Int>> {

    val commonElements = mutableListOf<Pair<String, Int>>()
    for (item1 in list1) {
        for (item2 in list2) {
            if (item1.first == item2.first && item1.second == item2.second) {
                commonElements.add(item1)
            }
        }
    }
    return commonElements
}
/**
 * Given two lists of tuples, find the common elements between them.
 *
 * @param list1 The first list of tuples.
 * @param list2 The second list of tuples.
 * @return A list of common elements.
 *
 * Example:
 * val list1 = listOf(Pair("apple", 5), Pair("orange", 8), Pair("banana", 4))
 * val list2 = listOf(Pair("apple", 5), Pair("grapes", 2), Pair("banana", 9))
 * findCommonElements(list1, list2)
 * Output: [("apple", 5)]
 */
fun findCommonElements(list1: List<Pair<String, Int>>, list2: List<Pair<String, Int>>): List<Pair<String, Int>> {
/**
 * Given two lists of tuples, find the common elements between them.
 *
 * @param list1 The first list of tuples.
 * @param list2 The second list of tuples.
 * @return A list of common elements.
 *
 * Example:
 * val list1 = listOf(Pair("apple", 5), Pair("orange", 8), Pair("banana", 4))
 * val list2 = listOf(Pair("apple", 5), Pair("grapes", 2), Pair("banana", 9))
 * findCommonElements(list1, list2)
 * Output: [("apple", 5)]
 */
fun findCommonElements(list1: List<Pair<String, Int>>, list2: List<Pair<String, Int>>): List<Pair<String, Int>> {

    val commonElements = mutableListOf<Pair<String, Int>>()
    for (item1 in list1) {
        for (item2 in list2) {
            if (item1.first == item2.first && item1.second == item2.second) {
                commonElements.add(item1)
            }
        }
    }
    return commonElements
}