Simple Java Solution


  • 0
    A

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


Log in to reply
 

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