/**
 * This function takes in two lists as arguments and returns a list containing the common elements of both lists.
 *
 * @param list1 the first list
 * @param list2 the second list
 * @return a list containing the common elements of list1 and list2
 *
 * Example:
 * val list1 = listOf(1, 2, 3, 4, 5)
 * val list2 = listOf(4, 5, 6, 7, 8)
 * getCommonElements(list1, list2) -> [4, 5]
 */
fun getCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (element in list1) {
        if (element in list2) {
            commonElements.add(element)
        }
    }
    return commonElements
}
/**
 * This function takes in two lists as arguments and returns a list containing the common elements of both lists.
 *
 * @param list1 the first list
 * @param list2 the second list
 * @return a list containing the common elements of list1 and list2
 *
 * Example:
 * val list1 = listOf(1, 2, 3, 4, 5)
 * val list2 = listOf(4, 5, 6, 7, 8)
 * getCommonElements(list1, list2) -> [4, 5]
 */
fun getCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This function takes in two lists as arguments and returns a list containing the common elements of both lists.
 *
 * @param list1 the first list
 * @param list2 the second list
 * @return a list containing the common elements of list1 and list2
 *
 * Example:
 * val list1 = listOf(1, 2, 3, 4, 5)
 * val list2 = listOf(4, 5, 6, 7, 8)
 * getCommonElements(list1, list2) -> [4, 5]
 */
fun getCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (element in list1) {
        if (element in list2) {
            commonElements.add(element)
        }
    }
    return commonElements
}