Remove Duplicates from Sorted Array IIFollow up for “Remove Duplicates”: For example, Your function should return length = 标签: Array Two Pointers 加一个变量记录一下元素出现的次数即可。这题因为是已经排序的数组,所以一个变量即可解决。如果是没有排序的数组,则需要引入一个hashmap来记录出现次数。 代码1
代码2
Java代码:
|
|
来自: 雪柳花明 > 《LeetCode》