Remove Element
Two Pointer
Problem
Given an array nums and a value val, remove all instances of that value in-place and return the new length.
For example:
Thought Process
We'll use two pointer approach: one pointer to iterate through the array and the other pointer to keep track of the position of the elements that aren't key. We will start from index 0.
Solution
Last updated
Was this helpful?