/**
 * Modify a specific value in a nested list at the given row and column index.
 *
 * @param nestedList The nested list to be modified.
 * @param row The row index of the element to be modified.
 * @param col The column index of the element to be modified.
 * @param value The new value to be assigned to the element.
 * @return The modified nested list.
 */
fun modifyNestedList(nestedList: List<List<Int>>, row: Int, col: Int, value: Int): List<List<Int>> {

    if (row < 0 || row >= nestedList.size || col < 0 || col >= nestedList[row].size) {
        return nestedList  // Invalid indices, return the original nested list as it is
    } else {
        return nestedList.mapIndexed { i, list ->
            list.mapIndexed { j, element ->
                if (i != row || j != col) element else value
            }
        }
    }
}
/**
 * Modify a specific value in a nested list at the given row and column index.
 *
 * @param nestedList The nested list to be modified.
 * @param row The row index of the element to be modified.
 * @param col The column index of the element to be modified.
 * @param value The new value to be assigned to the element.
 * @return The modified nested list.
 */
fun modifyNestedList(nestedList: List<List<Int>>, row: Int, col: Int, value: Int): List<List<Int>> {
/**
 * Modify a specific value in a nested list at the given row and column index.
 *
 * @param nestedList The nested list to be modified.
 * @param row The row index of the element to be modified.
 * @param col The column index of the element to be modified.
 * @param value The new value to be assigned to the element.
 * @return The modified nested list.
 */
fun modifyNestedList(nestedList: List<List<Int>>, row: Int, col: Int, value: Int): List<List<Int>> {

    if (row < 0 || row >= nestedList.size || col < 0 || col >= nestedList[row].size) {
        return nestedList  // Invalid indices, return the original nested list as it is
    } else {
        return nestedList.mapIndexed { i, list ->
            list.mapIndexed { j, element ->
                if (i != row || j != col) element else value
            }
        }
    }
}