Remove Element Java Solution


  • 2
    S
    public int removeElement(int[] nums, int val) {
         int i = 0;
         for(int num : nums){
        	 if(val != num){
        		 nums[i++] = num;
        	 }
         }
         return i;
    }

Log in to reply
 

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