/**
 * Given a list of positive integers 'nums' and a list of positive integers 'toRemove',
 * remove all occurrences of the numbers in 'toRemove' from 'nums' and return the modified list.
 *
 * @param nums A list of positive integers.
 * @param toRemove A list of positive integers to be removed from 'nums'.
 * @return A modified list with all occurrences of 'toRemove' elements removed.
 *
 * Example:
 * removeElements(listOf(1, 3, 4, 3, 5, 7), listOf(3, 5))
 * Output: [1, 4, 7]
 */
fun removeElements(nums: MutableList<Int>, toRemove: List<Int>): List<Int> {

    val toRemoveSet = toRemove.toSet()

    var i = 0
    while (i < nums.size) {
        val num = nums[i]
        if (num in toRemoveSet) {
            nums.removeAt(i)
        } else {
            i++
        }
    }

    return nums
}
/**
 * Given a list of positive integers 'nums' and a list of positive integers 'toRemove',
 * remove all occurrences of the numbers in 'toRemove' from 'nums' and return the modified list.
 *
 * @param nums A list of positive integers.
 * @param toRemove A list of positive integers to be removed from 'nums'.
 * @return A modified list with all occurrences of 'toRemove' elements removed.
 *
 * Example:
 * removeElements(listOf(1, 3, 4, 3, 5, 7), listOf(3, 5))
 * Output: [1, 4, 7]
 */
fun removeElements(nums: MutableList<Int>, toRemove: List<Int>): List<Int> {
/**
 * Given a list of positive integers 'nums' and a list of positive integers 'toRemove',
 * remove all occurrences of the numbers in 'toRemove' from 'nums' and return the modified list.
 *
 * @param nums A list of positive integers.
 * @param toRemove A list of positive integers to be removed from 'nums'.
 * @return A modified list with all occurrences of 'toRemove' elements removed.
 *
 * Example:
 * removeElements(listOf(1, 3, 4, 3, 5, 7), listOf(3, 5))
 * Output: [1, 4, 7]
 */
fun removeElements(nums: MutableList<Int>, toRemove: List<Int>): List<Int> {

    val toRemoveSet = toRemove.toSet()

    var i = 0
    while (i < nums.size) {
        val num = nums[i]
        if (num in toRemoveSet) {
            nums.removeAt(i)
        } else {
            i++
        }
    }

    return nums
}