Skip to content

Instantly share code, notes, and snippets.

@cangoal
Created June 2, 2015 19:10
Show Gist options
  • Save cangoal/1255e542593222887660 to your computer and use it in GitHub Desktop.
Save cangoal/1255e542593222887660 to your computer and use it in GitHub Desktop.
LeetCode - Remove Element
public int removeElement(int[] nums, int val) {
if(nums == null || nums.length == 0) return 0;
int k = 0;
for(int i=0; i<nums.length; i++){
if(nums[i] != val){
nums[k++] = nums[i];
}
}
return k;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment