Back to course home
0% completed
Vote For New Content
easy way
庞博
Dec 9, 2023
class Solution { public static int remove(int[] arr) { // TODO: Write your code here // 思路:数不重复的数 // idea: count non-duplicate number HashSet<Integer> set=new HashSet<Integer>(); for(int i:arr){ set.add(i); } return set.size(); } }
0
0
Comments
Comments
F
fede93ct 2 years ago
memory complexity is not O(1)
Sri2 years ago
set doesn't guarantee the order. how do you maintain the order in this case?