/**
 * Given a list 'data' and a target number, the task is to modify the list in such a way that each occurrence of
 * the target number is replaced by the square of its previous value (element at the previous index).
 *
 * Example:
 * Input:
 * data = [1, 2, 3, 4, 5, 6, 3, 4, 7, 3]
 * target = 3
 *
 * Output:
 * [1, 2, 4, 4, 5, 6, 36, 4, 7, 9]
 */
fun modifyList(data: MutableList<Int>, target: Int): List<Int> {

    for (i in 1 until data.size) {
        if (data[i] == target) {
            data[i] = data[i - 1] * data[i - 1]
        }
    }
    return data
}
/**
 * Given a list 'data' and a target number, the task is to modify the list in such a way that each occurrence of
 * the target number is replaced by the square of its previous value (element at the previous index).
 *
 * Example:
 * Input:
 * data = [1, 2, 3, 4, 5, 6, 3, 4, 7, 3]
 * target = 3
 *
 * Output:
 * [1, 2, 4, 4, 5, 6, 36, 4, 7, 9]
 */
fun modifyList(data: MutableList<Int>, target: Int): List<Int> {
/**
 * Given a list 'data' and a target number, the task is to modify the list in such a way that each occurrence of
 * the target number is replaced by the square of its previous value (element at the previous index).
 *
 * Example:
 * Input:
 * data = [1, 2, 3, 4, 5, 6, 3, 4, 7, 3]
 * target = 3
 *
 * Output:
 * [1, 2, 4, 4, 5, 6, 36, 4, 7, 9]
 */
fun modifyList(data: MutableList<Int>, target: Int): List<Int> {

    for (i in 1 until data.size) {
        if (data[i] == target) {
            data[i] = data[i - 1] * data[i - 1]
        }
    }
    return data
}