Simple Java Solution using inbuilt libraries


#1

public class Solution {
public int removeDuplicates(ArrayList a) {
ArrayList b=new ArrayList<>();
for(int i=0;i<a.size();i++)
{
if(b.contains(a.get(i)))
continue;
else
b.add(a.get(i));
}
a.clear();

    for(int i=0;i<b.size();i++)
    a.add(b.get(i));
    
    return a.size();
}

}


#2

This does not satisfy the condition that no extra space should be used.