/**
 * Given two lists 'a' and 'b' as input, write a function to find the common elements between them.
 * Use the 'in' operator and branching statements to solve this exercise.
 *
 * @param a The first list.
 * @param b The second list.
 * @return A new list containing the common elements between 'a' and 'b'.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findCommonElements(a: List<Int>, b: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    for (element in a) {
        if (element !in commonElements) {
            if (element in b) {
                commonElements.add(element)
            }
        }
    }

    return commonElements
}
/**
 * Given two lists 'a' and 'b' as input, write a function to find the common elements between them.
 * Use the 'in' operator and branching statements to solve this exercise.
 *
 * @param a The first list.
 * @param b The second list.
 * @return A new list containing the common elements between 'a' and 'b'.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findCommonElements(a: List<Int>, b: List<Int>): List<Int> {
/**
 * Given two lists 'a' and 'b' as input, write a function to find the common elements between them.
 * Use the 'in' operator and branching statements to solve this exercise.
 *
 * @param a The first list.
 * @param b The second list.
 * @return A new list containing the common elements between 'a' and 'b'.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findCommonElements(a: List<Int>, b: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    for (element in a) {
        if (element !in commonElements) {
            if (element in b) {
                commonElements.add(element)
            }
        }
    }

    return commonElements
}