/**
 * This function checks if two lists have common elements.
 *
 * @return "Both lists have common elements" if there are common elements, "Lists have no common elements" otherwise.
 */
fun checkCommonElements(): String {

    val list1 = listOf(1, 2, 3, 4, 5)
    val list2 = listOf(4, 5, 6, 7, 8)

    val commonElements = findCommonElements(list1, list2)

    return if (commonElements.isNotEmpty()) {
        "Both lists have common elements"
    } else {
        "Lists have no common elements"
    }
}

fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
    return list1.intersect(list2).toList()
}
/**
 * This function checks if two lists have common elements.
 *
 * @return "Both lists have common elements" if there are common elements, "Lists have no common elements" otherwise.
 */
fun checkCommonElements(): String {
/**
 * This function checks if two lists have common elements.
 *
 * @return "Both lists have common elements" if there are common elements, "Lists have no common elements" otherwise.
 */
fun checkCommonElements(): String {

    val list1 = listOf(1, 2, 3, 4, 5)
    val list2 = listOf(4, 5, 6, 7, 8)

    val commonElements = findCommonElements(list1, list2)

    return if (commonElements.isNotEmpty()) {
        "Both lists have common elements"
    } else {
        "Lists have no common elements"
    }
}

fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
    return list1.intersect(list2).toList()
}