/**
 * Given two lists, return a new list containing the intersection of the two lists
 * only using the 'in" statement and the 'and" operator.
 *
 * @param list1 First list.
 * @param list2 Second list.
 * @return List containing the common elements between list1 and list2.
 *
 * Example:
 * intersectionCheck(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 */
fun intersectionCheck(list1: List<Int>, list2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    for (item in list1) {
        if (item in list2 && item !in intersection) {
            intersection.add(item)
        }
    }
    return intersection
}
/**
 * Given two lists, return a new list containing the intersection of the two lists
 * only using the 'in" statement and the 'and" operator.
 *
 * @param list1 First list.
 * @param list2 Second list.
 * @return List containing the common elements between list1 and list2.
 *
 * Example:
 * intersectionCheck(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 */
fun intersectionCheck(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, return a new list containing the intersection of the two lists
 * only using the 'in" statement and the 'and" operator.
 *
 * @param list1 First list.
 * @param list2 Second list.
 * @return List containing the common elements between list1 and list2.
 *
 * Example:
 * intersectionCheck(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 */
fun intersectionCheck(list1: List<Int>, list2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    for (item in list1) {
        if (item in list2 && item !in intersection) {
            intersection.add(item)
        }
    }
    return intersection
}