[27] LeetCode. Remove elements (simple array)

Title:
Here Insert Picture Description
The title 26 questions and is very similar to
Java code:

class Solution {
    public int removeElement(int[] nums, int val) {
        int i=0,j=0;
        while(j<nums.length){
            if(nums[j]!=val){
                nums[i]=nums[j];
                i++;
            }
            j++;
        }
       return i; 
    }
}

Here Insert Picture Description

Published 125 original articles · won praise 56 · views 70000 +

Guess you like

Origin blog.csdn.net/Nicht_sehen/article/details/102904397