Remove Element
Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. Return the number of elements in nums which are not equal to val.

30:00

Remove Element
easy
Topics
Companies

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. Return the number of elements in nums which are not equal to val.

Example 1:
Input: {"nums":[3,2,2,3],"val":3}
Output: 2
Constraints:
  • 0nums.length1000 \leq \text{nums.length} \leq 100

  • 0nums[i]500 \leq \text{nums}[i] \leq 50

  • 0val1000 \leq \text{val} \leq 100

Input
arr ={"nums":[3,2,2,3],"val":3}

Remove all 3

Remove value: 3

ki30212233
k (write): 0
i (read): 0
Kept: 0
Variables
VariableValue
val3
DepthFunction Call
Stack empty
0/5