/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first list
 * @param list2 The second list
 * @return A set containing the common elements between list1 and list2
 */
fun findCommonElements(list1: MutableList<Int>, list2: MutableList<Int>): Set<Int> {

    val intersectionSet = mutableSetOf<Int>()

    // Iterate through the elements of list1
    while (list1.isNotEmpty()) {
        val element = list1.removeAt(list1.size - 1)

        // Iterate through the elements of list2
        val iterator = list2.iterator()
        while (iterator.hasNext()) {
            val compareElement = iterator.next()

            // Compare element and compareElement
            if (element == compareElement) {
                intersectionSet.add(element)
            }
        }
    }

    return intersectionSet
}
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first list
 * @param list2 The second list
 * @return A set containing the common elements between list1 and list2
 */
fun findCommonElements(list1: MutableList<Int>, list2: MutableList<Int>): Set<Int> {
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first list
 * @param list2 The second list
 * @return A set containing the common elements between list1 and list2
 */
fun findCommonElements(list1: MutableList<Int>, list2: MutableList<Int>): Set<Int> {

    val intersectionSet = mutableSetOf<Int>()

    // Iterate through the elements of list1
    while (list1.isNotEmpty()) {
        val element = list1.removeAt(list1.size - 1)

        // Iterate through the elements of list2
        val iterator = list2.iterator()
        while (iterator.hasNext()) {
            val compareElement = iterator.next()

            // Compare element and compareElement
            if (element == compareElement) {
                intersectionSet.add(element)
            }
        }
    }

    return intersectionSet
}