/**
 * Write a function that takes in two lists, 'data1" and 'data2`, which contains data related to biological studies.
 * The function should return a list containing only the elements that exist in both 'data1" and 'data2`, preserving the order.
 *
 * Example:
 * val data1 = listOf("AGT", "CTG", "GGA", "AAC")
 * val data2 = listOf("AAG", "CTG", "TGC", "ATC")
 *
 * findCommonElements(data1, data2)  // Output: ["CTG"]
 */
fun findCommonElements(data1: List<String>, data2: List<String>): List<String> {

    val commonElements = mutableListOf<String>()
    // Iterate through each element of data1
    for (elem in data1) {
        // Check if the element exists in data2
        if (elem in data2) {
            // Add the element to the commonElements list
            commonElements.add(elem)
        }
    }
    return commonElements
}
/**
 * Write a function that takes in two lists, 'data1" and 'data2`, which contains data related to biological studies.
 * The function should return a list containing only the elements that exist in both 'data1" and 'data2`, preserving the order.
 *
 * Example:
 * val data1 = listOf("AGT", "CTG", "GGA", "AAC")
 * val data2 = listOf("AAG", "CTG", "TGC", "ATC")
 *
 * findCommonElements(data1, data2)  // Output: ["CTG"]
 */
fun findCommonElements(data1: List<String>, data2: List<String>): List<String> {
/**
 * Write a function that takes in two lists, 'data1" and 'data2`, which contains data related to biological studies.
 * The function should return a list containing only the elements that exist in both 'data1" and 'data2`, preserving the order.
 *
 * Example:
 * val data1 = listOf("AGT", "CTG", "GGA", "AAC")
 * val data2 = listOf("AAG", "CTG", "TGC", "ATC")
 *
 * findCommonElements(data1, data2)  // Output: ["CTG"]
 */
fun findCommonElements(data1: List<String>, data2: List<String>): List<String> {

    val commonElements = mutableListOf<String>()
    // Iterate through each element of data1
    for (elem in data1) {
        // Check if the element exists in data2
        if (elem in data2) {
            // Add the element to the commonElements list
            commonElements.add(elem)
        }
    }
    return commonElements
}