/**
 * This function checks for the common elements between two lists using the 'in' operator
 * and exits the while loop once a common element is found.
 */
fun findCommonElements(list1: MutableList<Int>, list2: MutableList<Int>): MutableList<Int> {

    // Sort the lists
    list1.sort()
    list2.sort()

    // Initialize variables
    val commonElements = mutableListOf<Int>()
    var i = 0
    var j = 0

    // Find common elements using the 'in' operator and exit the while loop
    while (i < list1.size && j < list2.size) {
        if (list1[i] == list2[j]) {
            commonElements.add(list1[i])
            break
        } else if (list1[i] < list2[j]) {
            i++
        } else {
            j++
        }
    }

    return commonElements
}
/**
 * This function checks for the common elements between two lists using the 'in' operator
 * and exits the while loop once a common element is found.
 */
fun findCommonElements(list1: MutableList<Int>, list2: MutableList<Int>): MutableList<Int> {
/**
 * This function checks for the common elements between two lists using the 'in' operator
 * and exits the while loop once a common element is found.
 */
fun findCommonElements(list1: MutableList<Int>, list2: MutableList<Int>): MutableList<Int> {

    // Sort the lists
    list1.sort()
    list2.sort()

    // Initialize variables
    val commonElements = mutableListOf<Int>()
    var i = 0
    var j = 0

    // Find common elements using the 'in' operator and exit the while loop
    while (i < list1.size && j < list2.size) {
        if (list1[i] == list2[j]) {
            commonElements.add(list1[i])
            break
        } else if (list1[i] < list2[j]) {
            i++
        } else {
            j++
        }
    }

    return commonElements
}