/**
 * Given two lists, find the common elements between them and
 * change each element of the common elements list to 0.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The list with common elements changed to 0.
 *
 * Examples:
 * commonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [0, 0, 3, 4]
 * commonElements(listOf("apple", "banana", "orange"), listOf("banana", "grape", "kiwi")) // ["banana", 0, 0]
 */
fun commonElements(list1: MutableList<Any>, list2: List<Any>): List<Any> {

    val common = mutableListOf<Any>()
    
    for (item in list1) {
        if (item in list2) {
            common.add(item)
        }
    }
    
    for (i in common.indices) {
        val index = list1.indexOf(common[i])
        list1[index] = 0
    }
    
    return list1
}
/**
 * Given two lists, find the common elements between them and
 * change each element of the common elements list to 0.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The list with common elements changed to 0.
 *
 * Examples:
 * commonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [0, 0, 3, 4]
 * commonElements(listOf("apple", "banana", "orange"), listOf("banana", "grape", "kiwi")) // ["banana", 0, 0]
 */
fun commonElements(list1: MutableList<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the common elements between them and
 * change each element of the common elements list to 0.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The list with common elements changed to 0.
 *
 * Examples:
 * commonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [0, 0, 3, 4]
 * commonElements(listOf("apple", "banana", "orange"), listOf("banana", "grape", "kiwi")) // ["banana", 0, 0]
 */
fun commonElements(list1: MutableList<Any>, list2: List<Any>): List<Any> {

    val common = mutableListOf<Any>()
    
    for (item in list1) {
        if (item in list2) {
            common.add(item)
        }
    }
    
    for (i in common.indices) {
        val index = list1.indexOf(common[i])
        list1[index] = 0
    }
    
    return list1
}