Given an array nums and a value val, return a new array with every occurrence of val removed.
nums
val
The relative order of the remaining elements must be kept.
nums = [3,2,2,3], val = 3
[2,2]
nums = [0,1,2,2,3,0,4,2], val = 2
[0,1,3,0,4]
0 <= nums.length <= 100 0 <= nums[i], val <= 50
Topics
Implement removeElement in the editor and return the answer — printing it is never graded.
removeElement
Problem 47 of 1146 in the arena