Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 402 Bytes

27 Remove Element 1c502226a1614830b330f912db240862.md

File metadata and controls

19 lines (16 loc) · 402 Bytes

27. Remove Element

Remove Element - LeetCode

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

        return k;
    }
}