/**
 * In this exercise, you need to write a function that takes two lists as input. The function should iterate over each
 * element in the first list and multiply it with the corresponding element in the second list. The updated values should
 * be stored back in the first list. Your objective is to modify the first list directly using loops and the multiplication
 * assignment operator. Return the modified list.
 *
 * @param list1 First list of numbers
 * @param list2 Second list of numbers (must have the same length as list1)
 * @return Modified list1 with updated values
 *
 * Example:
 * modifyListWithLoops(listOf(1, 2, 3), listOf(2, 3, 4))
 * Output: [2, 6, 12]
 */
fun modifyListWithLoops(list1: MutableList<Int>, list2: List<Int>): List<Int> {

    // Check if the lengths of the lists are equal
    if (list1.size != list2.size) {
        return listOf(-1) // Error: The lists must have the same length.
    }

    // Iterate over each element in the lists
    for (i in list1.indices) {
        // Multiply the corresponding elements and store the updated value in the first list
        list1[i] *= list2[i]
    }

    return list1
}
/**
 * In this exercise, you need to write a function that takes two lists as input. The function should iterate over each
 * element in the first list and multiply it with the corresponding element in the second list. The updated values should
 * be stored back in the first list. Your objective is to modify the first list directly using loops and the multiplication
 * assignment operator. Return the modified list.
 *
 * @param list1 First list of numbers
 * @param list2 Second list of numbers (must have the same length as list1)
 * @return Modified list1 with updated values
 *
 * Example:
 * modifyListWithLoops(listOf(1, 2, 3), listOf(2, 3, 4))
 * Output: [2, 6, 12]
 */
fun modifyListWithLoops(list1: MutableList<Int>, list2: List<Int>): List<Int> {
/**
 * In this exercise, you need to write a function that takes two lists as input. The function should iterate over each
 * element in the first list and multiply it with the corresponding element in the second list. The updated values should
 * be stored back in the first list. Your objective is to modify the first list directly using loops and the multiplication
 * assignment operator. Return the modified list.
 *
 * @param list1 First list of numbers
 * @param list2 Second list of numbers (must have the same length as list1)
 * @return Modified list1 with updated values
 *
 * Example:
 * modifyListWithLoops(listOf(1, 2, 3), listOf(2, 3, 4))
 * Output: [2, 6, 12]
 */
fun modifyListWithLoops(list1: MutableList<Int>, list2: List<Int>): List<Int> {

    // Check if the lengths of the lists are equal
    if (list1.size != list2.size) {
        return listOf(-1) // Error: The lists must have the same length.
    }

    // Iterate over each element in the lists
    for (i in list1.indices) {
        // Multiply the corresponding elements and store the updated value in the first list
        list1[i] *= list2[i]
    }

    return list1
}