/**
 * Given two lists, find the common elements and return them.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    try {
        // Iterate over the elements of the first list
        for (element in list1) {
            try {
                // Check if the element is also present in the second list
                if (list2.contains(element)) {
                    commonElements.add(element)
                }
            } catch (e: Exception) {
                continue
            }
        }
    } catch (e: Exception) {
        // Handle exception
    }

    return commonElements
}
/**
 * Given two lists, find the common elements and return them.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, find the common elements and return them.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    try {
        // Iterate over the elements of the first list
        for (element in list1) {
            try {
                // Check if the element is also present in the second list
                if (list2.contains(element)) {
                    commonElements.add(element)
                }
            } catch (e: Exception) {
                continue
            }
        }
    } catch (e: Exception) {
        // Handle exception
    }

    return commonElements
}