/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 A list of integers representing the indices
 * @param list2 A list of integers representing the indices
 * @return A list of common elements found in both lists
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate over the indices of list1
    for (i in list1.indices) {
        // Iterate over the indices of list2
        for (j in list2.indices) {
            // Check if element at index i in list1 is equal to element at index j in list2
            if (list1[i] == list2[j]) {
                // Check if the common element is not already in the commonElements list
                if (!commonElements.contains(list1[i])) {
                    commonElements.add(list1[i])
                }
            }
        }
    }

    return commonElements
}
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 A list of integers representing the indices
 * @param list2 A list of integers representing the indices
 * @return A list of common elements found in both lists
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 A list of integers representing the indices
 * @param list2 A list of integers representing the indices
 * @return A list of common elements found in both lists
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate over the indices of list1
    for (i in list1.indices) {
        // Iterate over the indices of list2
        for (j in list2.indices) {
            // Check if element at index i in list1 is equal to element at index j in list2
            if (list1[i] == list2[j]) {
                // Check if the common element is not already in the commonElements list
                if (!commonElements.contains(list1[i])) {
                    commonElements.add(list1[i])
                }
            }
        }
    }

    return commonElements
}