Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int removeElement(int[] nums, int val) {
- int index = 0;
- for (int i = 0; i < nums.length; i++) {
- if (nums[i] != val) {
- // Gather values that are not equal to 'val'
- // at the beginning of the array, one-by-one.
- nums[index] = nums[i];
- index++;
- }
- }
- return index;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement