JAVA----------------Easy Version To Understand!!!!!!!!!


  • 0
    H
        public static int removeElement(int[] nums, int val) {
    	if(nums==null||nums.length==0)
    		return 0;
    	
    	int slow=0,fast=0,len=nums.length;
    	while(fast<len){
    		if(nums[fast]!=val){
    			nums[slow++]=nums[fast];
    		}
                fast++;			
      	}
        return slow;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.