/**
 * Given two lists of rock samples, return a list of common elements using nested if-else statements and list comprehension.
 *
 * @param rockSamples1 A list of rock samples containing unique elements.
 * @param rockSamples2 A list of rock samples containing unique elements.
 * @return A list of common elements found in both rockSamples1 and rockSamples2.
 */
fun findCommonElements(rockSamples1: List<String>, rockSamples2: List<String>): List<String> {

    val result = mutableListOf<String>()
    for (sample1 in rockSamples1) {
        if (sample1 in rockSamples2) {
            if (sample1 !in result) {
                result.add(sample1)
            }
        }
    }
    return result.toList()
}
/**
 * Given two lists of rock samples, return a list of common elements using nested if-else statements and list comprehension.
 *
 * @param rockSamples1 A list of rock samples containing unique elements.
 * @param rockSamples2 A list of rock samples containing unique elements.
 * @return A list of common elements found in both rockSamples1 and rockSamples2.
 */
fun findCommonElements(rockSamples1: List<String>, rockSamples2: List<String>): List<String> {
/**
 * Given two lists of rock samples, return a list of common elements using nested if-else statements and list comprehension.
 *
 * @param rockSamples1 A list of rock samples containing unique elements.
 * @param rockSamples2 A list of rock samples containing unique elements.
 * @return A list of common elements found in both rockSamples1 and rockSamples2.
 */
fun findCommonElements(rockSamples1: List<String>, rockSamples2: List<String>): List<String> {

    val result = mutableListOf<String>()
    for (sample1 in rockSamples1) {
        if (sample1 in rockSamples2) {
            if (sample1 !in result) {
                result.add(sample1)
            }
        }
    }
    return result.toList()
}