/**
 * This exercise requires you to write a function that finds the intersection
 * of two given lists using the AND operator. The function should return a new
 * list containing only the common elements from both lists. You need to complete
 * the missing code inside the function.
 */
fun intersectionAndOperatorEmptyLists(list1: List<Int>, list2: List<Int>): List<Int> {

    val result = mutableListOf<Int>() // Create an empty list to store the intersection

    // Check if any of the input lists is empty
    if (list1.isEmpty() || list2.isEmpty()) {
        return result
    }

    // Iterate over the elements in list1
    for (element1 in list1) {
        // Iterate over the elements in list2
        for (element2 in list2) {
            // Check if the elements in both lists are the same
            if (element1 == element2) {
                // Append the common element to the result list
                result.add(element1)
                break // Break out of the inner loop to avoid duplicates
            }
        }
    }

    return result
}
/**
 * This exercise requires you to write a function that finds the intersection
 * of two given lists using the AND operator. The function should return a new
 * list containing only the common elements from both lists. You need to complete
 * the missing code inside the function.
 */
fun intersectionAndOperatorEmptyLists(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This exercise requires you to write a function that finds the intersection
 * of two given lists using the AND operator. The function should return a new
 * list containing only the common elements from both lists. You need to complete
 * the missing code inside the function.
 */
fun intersectionAndOperatorEmptyLists(list1: List<Int>, list2: List<Int>): List<Int> {

    val result = mutableListOf<Int>() // Create an empty list to store the intersection

    // Check if any of the input lists is empty
    if (list1.isEmpty() || list2.isEmpty()) {
        return result
    }

    // Iterate over the elements in list1
    for (element1 in list1) {
        // Iterate over the elements in list2
        for (element2 in list2) {
            // Check if the elements in both lists are the same
            if (element1 == element2) {
                // Append the common element to the result list
                result.add(element1)
                break // Break out of the inner loop to avoid duplicates
            }
        }
    }

    return result
}