/**
 * Given two lists, listA and listB, determine the intersection of the lists using nested loops,
 * break and continue statements, and slicing.
 *
 * @param listA A list containing elements. (List<Int>)
 * @param listB A list containing elements. (List<Int>)
 * @return intersection A list containing the common elements between listA and listB.
 */
fun intersectionNestedLoopsAndSlicing(listA: List<Int>, listB: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    // Nested loops to iterate through each element in both lists
    for (a in listA) {
        for (b in listB) {
            if (a == b) {
                // Appending the common element to the intersection list
                intersection.add(a)
                break
            }
        }
    }

    return intersection
}
/**
 * Given two lists, listA and listB, determine the intersection of the lists using nested loops,
 * break and continue statements, and slicing.
 *
 * @param listA A list containing elements. (List<Int>)
 * @param listB A list containing elements. (List<Int>)
 * @return intersection A list containing the common elements between listA and listB.
 */
fun intersectionNestedLoopsAndSlicing(listA: List<Int>, listB: List<Int>): List<Int> {
/**
 * Given two lists, listA and listB, determine the intersection of the lists using nested loops,
 * break and continue statements, and slicing.
 *
 * @param listA A list containing elements. (List<Int>)
 * @param listB A list containing elements. (List<Int>)
 * @return intersection A list containing the common elements between listA and listB.
 */
fun intersectionNestedLoopsAndSlicing(listA: List<Int>, listB: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    // Nested loops to iterate through each element in both lists
    for (a in listA) {
        for (b in listB) {
            if (a == b) {
                // Appending the common element to the intersection list
                intersection.add(a)
                break
            }
        }
    }

    return intersection
}