/**
 * This function takes two lists as input and returns the intersection of the two lists.
 * It uses nested loops and short-circuiting to optimize the process.
 *
 * @param arr1 First input list
 * @param arr2 Second input list
 * @return Intersection of the two input lists
 */
fun intersectionCheck(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    for (i in arr1) {
        for (j in arr2) {
            if (i == j) {
                intersection.add(i)
                break  // Short-circuiting if intersection found
            }
        }
    }
    return intersection
}
/**
 * This function takes two lists as input and returns the intersection of the two lists.
 * It uses nested loops and short-circuiting to optimize the process.
 *
 * @param arr1 First input list
 * @param arr2 Second input list
 * @return Intersection of the two input lists
 */
fun intersectionCheck(arr1: List<Int>, arr2: List<Int>): List<Int> {
/**
 * This function takes two lists as input and returns the intersection of the two lists.
 * It uses nested loops and short-circuiting to optimize the process.
 *
 * @param arr1 First input list
 * @param arr2 Second input list
 * @return Intersection of the two input lists
 */
fun intersectionCheck(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    for (i in arr1) {
        for (j in arr2) {
            if (i == j) {
                intersection.add(i)
                break  // Short-circuiting if intersection found
            }
        }
    }
    return intersection
}