/**
 * This function takes two lists of bird species as arguments and returns the common bird species
 * that are present in both lists. The function assumes that the bird lists are sorted in alphabetical order.
 *
 * @param birdList1 A sorted list of bird species
 * @param birdList2 A sorted list of bird species
 * @return A sorted list of common bird species present in both lists
 */
fun findCommonBirds(birdList1: List<String>, birdList2: List<String>): List<String> {

    val commonBirds = mutableListOf<String>()

    var i = 0
    var j = 0
    while (i < birdList1.size && j < birdList2.size) {
        when {
            birdList1[i] == birdList2[j] -> {
                commonBirds.add(birdList1[i])
                i++
                j++
            }
            birdList1[i] < birdList2[j] -> i++
            else -> j++
        }
    }

    return commonBirds
}
/**
 * This function takes two lists of bird species as arguments and returns the common bird species
 * that are present in both lists. The function assumes that the bird lists are sorted in alphabetical order.
 *
 * @param birdList1 A sorted list of bird species
 * @param birdList2 A sorted list of bird species
 * @return A sorted list of common bird species present in both lists
 */
fun findCommonBirds(birdList1: List<String>, birdList2: List<String>): List<String> {
/**
 * This function takes two lists of bird species as arguments and returns the common bird species
 * that are present in both lists. The function assumes that the bird lists are sorted in alphabetical order.
 *
 * @param birdList1 A sorted list of bird species
 * @param birdList2 A sorted list of bird species
 * @return A sorted list of common bird species present in both lists
 */
fun findCommonBirds(birdList1: List<String>, birdList2: List<String>): List<String> {

    val commonBirds = mutableListOf<String>()

    var i = 0
    var j = 0
    while (i < birdList1.size && j < birdList2.size) {
        when {
            birdList1[i] == birdList2[j] -> {
                commonBirds.add(birdList1[i])
                i++
                j++
            }
            birdList1[i] < birdList2[j] -> i++
            else -> j++
        }
    }

    return commonBirds
}