/**
 * Given two lists, replace the common elements in both lists with the string 'REPLACED'.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The modified first list.
 *
 * Example:
 * replaceCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) -> [1, 2, 'REPLACED', 'REPLACED']
 */
fun replaceCommonElements(list1: MutableList<Any>, list2: List<Any>): List<Any> {

    for (i in list1.indices) {
        if (list1[i] in list2) {
            list1[i] = "REPLACED"
        }
    }
    return list1
}
/**
 * Given two lists, replace the common elements in both lists with the string 'REPLACED'.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The modified first list.
 *
 * Example:
 * replaceCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) -> [1, 2, 'REPLACED', 'REPLACED']
 */
fun replaceCommonElements(list1: MutableList<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, replace the common elements in both lists with the string 'REPLACED'.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The modified first list.
 *
 * Example:
 * replaceCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) -> [1, 2, 'REPLACED', 'REPLACED']
 */
fun replaceCommonElements(list1: MutableList<Any>, list2: List<Any>): List<Any> {

    for (i in list1.indices) {
        if (list1[i] in list2) {
            list1[i] = "REPLACED"
        }
    }
    return list1
}