/**
 * Given two lists of integers, count the number of elements that appear in both lists.
 *
 * @param list1 The first list of integers.
 * @param list2 The second list of integers.
 * @return The count of common elements between the two lists.
 *
 * Example:
 * countIntersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => 2
 * countIntersection(listOf(10, 20, 30), listOf(30, 40, 50)) => 1
 */
fun countIntersection(list1: List<Int>, list2: List<Int>): Int {

    var commonCount = 0

    for (i in list1.indices) {
        for (j in list2.indices) {
            if (list1[i] == list2[j]) {
                commonCount++
            }
        }
    }

    return commonCount
}
/**
 * Given two lists of integers, count the number of elements that appear in both lists.
 *
 * @param list1 The first list of integers.
 * @param list2 The second list of integers.
 * @return The count of common elements between the two lists.
 *
 * Example:
 * countIntersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => 2
 * countIntersection(listOf(10, 20, 30), listOf(30, 40, 50)) => 1
 */
fun countIntersection(list1: List<Int>, list2: List<Int>): Int {
/**
 * Given two lists of integers, count the number of elements that appear in both lists.
 *
 * @param list1 The first list of integers.
 * @param list2 The second list of integers.
 * @return The count of common elements between the two lists.
 *
 * Example:
 * countIntersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => 2
 * countIntersection(listOf(10, 20, 30), listOf(30, 40, 50)) => 1
 */
fun countIntersection(list1: List<Int>, list2: List<Int>): Int {

    var commonCount = 0

    for (i in list1.indices) {
        for (j in list2.indices) {
            if (list1[i] == list2[j]) {
                commonCount++
            }
        }
    }

    return commonCount
}