/**
 * This function takes two lists as input and returns a dictionary containing the common elements
 * and their respective index positions in both lists.
 *
 * @param list1 A list of elements.
 * @param list2 A list of elements.
 * @return A dictionary containing the common elements and their index positions in both lists.
 */
fun findCommonElements(list1: List<String>, list2: List<String>): Map<String, List<Int>> {

    val commonElements = mutableMapOf<String, List<Int>>()

    for (i in list1.indices) {
        val element = list1[i]
        if (element in list2 && element !in commonElements) {
            commonElements[element] = listOf(i, list2.indexOf(element))
        }
    }

    return commonElements
}

// Task:
// Given two lists of DNA sequences, find the common sequences in both lists and return a dictionary
// with the DNA sequence as the key and its respective index positions in both lists as the value.
// Both of the lists are already present for you.

val list1 = listOf(
    "ACGGTACGCTAGCGTAGCTAGCTAGCTAGCGTAGCTACGTAGCTGACTGAC",
    "GCTAGATCGTACGTACGTCAGTACGTACGTACGTAGCTAGCTAG"
)
/**
 * This function takes two lists as input and returns a dictionary containing the common elements
 * and their respective index positions in both lists.
 *
 * @param list1 A list of elements.
 * @param list2 A list of elements.
 * @return A dictionary containing the common elements and their index positions in both lists.
 */
fun findCommonElements(list1: List<String>, list2: List<String>): Map<String, List<Int>> {
/**
 * This function takes two lists as input and returns a dictionary containing the common elements
 * and their respective index positions in both lists.
 *
 * @param list1 A list of elements.
 * @param list2 A list of elements.
 * @return A dictionary containing the common elements and their index positions in both lists.
 */
fun findCommonElements(list1: List<String>, list2: List<String>): Map<String, List<Int>> {

    val commonElements = mutableMapOf<String, List<Int>>()

    for (i in list1.indices) {
        val element = list1[i]
        if (element in list2 && element !in commonElements) {
            commonElements[element] = listOf(i, list2.indexOf(element))
        }
    }

    return commonElements
}

// Task:
// Given two lists of DNA sequences, find the common sequences in both lists and return a dictionary
// with the DNA sequence as the key and its respective index positions in both lists as the value.
// Both of the lists are already present for you.

val list1 = listOf(
    "ACGGTACGCTAGCGTAGCTAGCTAGCTAGCGTAGCTACGTAGCTGACTGAC",
    "GCTAGATCGTACGTACGTCAGTACGTACGTACGTAGCTAGCTAG"
)