/**
 * Find the common elements between two lists using slicing and modulus.
 *
 * @param lst1 The first list.
 * @param lst2 The second list.
 * @return A list containing the common elements between lst1 and lst2.
 */
fun findCommonElements(lst1: List<Int>, lst2: List<Int>): List<Int> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Int>()

    // Check if both lists have elements
    if (lst1.isNotEmpty() && lst2.isNotEmpty()) {
        // Sort the lists in ascending order
        val sortedLst1 = lst1.sorted()
        val sortedLst2 = lst2.sorted()

        // Iterate through each element in lst1
        for (element in sortedLst1) {
            // Check if the element is present in lst2 using modulus
            if (element in sortedLst2.slice(element % sortedLst2.size until sortedLst2.size)) {
                // Append the common element to the list
                commonElements.add(element)
            }
        }
    }

    return commonElements
}
/**
 * Find the common elements between two lists using slicing and modulus.
 *
 * @param lst1 The first list.
 * @param lst2 The second list.
 * @return A list containing the common elements between lst1 and lst2.
 */
fun findCommonElements(lst1: List<Int>, lst2: List<Int>): List<Int> {
/**
 * Find the common elements between two lists using slicing and modulus.
 *
 * @param lst1 The first list.
 * @param lst2 The second list.
 * @return A list containing the common elements between lst1 and lst2.
 */
fun findCommonElements(lst1: List<Int>, lst2: List<Int>): List<Int> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Int>()

    // Check if both lists have elements
    if (lst1.isNotEmpty() && lst2.isNotEmpty()) {
        // Sort the lists in ascending order
        val sortedLst1 = lst1.sorted()
        val sortedLst2 = lst2.sorted()

        // Iterate through each element in lst1
        for (element in sortedLst1) {
            // Check if the element is present in lst2 using modulus
            if (element in sortedLst2.slice(element % sortedLst2.size until sortedLst2.size)) {
                // Append the common element to the list
                commonElements.add(element)
            }
        }
    }

    return commonElements
}