/**
 * Given two lists, find the common elements between them using nested while loops and short-circuiting.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    var i = 0
    while (i < list1.size) {
        var j = 0
        while (j < list2.size) {
            if (list1[i] == list2[j]) {
                commonElements.add(list1[i])
                i++
                break
            }
            j++
        }
        i++
    }
    return commonElements
}
/**
 * Given two lists, find the common elements between them using nested while loops and short-circuiting.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the common elements between them using nested while loops and short-circuiting.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    var i = 0
    while (i < list1.size) {
        var j = 0
        while (j < list2.size) {
            if (list1[i] == list2[j]) {
                commonElements.add(list1[i])
                i++
                break
            }
            j++
        }
        i++
    }
    return commonElements
}