时间自由度为o(n),空间自由度为o(1); class Solution {public: /** * @param A: a list of integers * @return : return an integer */ int removeDuplicates(vector<int> &nums) { // write your code here if(nums.empty()) {
在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index,不然会报错 <div class="" ng-init="names=[1,2,3,4,5,5]"> <p>循环对象:</p> <ul> <li ng-repeat="x in names track by $index"> {{ x }}</li> &
Array类型并没有提供去重复的方法,如果要把数组的重复元素干掉,那得自己想办法: function unique(arr) { var result = [], isRepeated; for (var i = 0, len = arr.length; i < len; i++) { isRepeated = false; for (var j = 0, len = result.length; j < len; j++) { if (arr[i] == result[j]) { isRep