/**
 * Given two lists 'list1' and 'list2', find the intersection of the two lists using list comprehension.
 *
 * The intersection of two lists is a new list containing only the elements that are present in both lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection of 'list1' and 'list2'.
 *
 * Example:
 * intersectionOfLists([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) -> [4, 5]
 * intersectionOfLists([10, 20, 30, 40, 50], [30, 40, 50, 60, 70]) -> [30, 40, 50]
 * intersectionOfLists([1, 2, 3], []) -> []
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {

    // Find the intersection of the two lists
    val intersection = list1.filter { it in list2 }
    
    return intersection
}
/**
 * Given two lists 'list1' and 'list2', find the intersection of the two lists using list comprehension.
 *
 * The intersection of two lists is a new list containing only the elements that are present in both lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection of 'list1' and 'list2'.
 *
 * Example:
 * intersectionOfLists([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) -> [4, 5]
 * intersectionOfLists([10, 20, 30, 40, 50], [30, 40, 50, 60, 70]) -> [30, 40, 50]
 * intersectionOfLists([1, 2, 3], []) -> []
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists 'list1' and 'list2', find the intersection of the two lists using list comprehension.
 *
 * The intersection of two lists is a new list containing only the elements that are present in both lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection of 'list1' and 'list2'.
 *
 * Example:
 * intersectionOfLists([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) -> [4, 5]
 * intersectionOfLists([10, 20, 30, 40, 50], [30, 40, 50, 60, 70]) -> [30, 40, 50]
 * intersectionOfLists([1, 2, 3], []) -> []
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {

    // Find the intersection of the two lists
    val intersection = list1.filter { it in list2 }
    
    return intersection
}