一开始写的是num[i]和nums[i+1],存在数组越界的问题,以后多用i-1避免数组越界,多亏北航的一个学长。 ...
分类:
其他好文 时间:
2019-02-16 10:43:04
阅读次数:
177
Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: 1 class Solution { 2 public: 3 vector<v ...
分类:
其他好文 时间:
2019-02-07 19:05:26
阅读次数:
151
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the ...
分类:
其他好文 时间:
2019-02-07 09:12:45
阅读次数:
175
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the ...
分类:
其他好文 时间:
2019-02-03 18:11:43
阅读次数:
150
算法描述: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For exa ...
分类:
其他好文 时间:
2019-02-03 11:08:11
阅读次数:
193
算法描述: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For ex ...
分类:
其他好文 时间:
2019-02-03 10:41:35
阅读次数:
198
[toc] 题目链接 "Remove Duplicates from Sorted Array LeetCode" 注意点 解法二要考虑输入为空的情况 解法 解法一:只要两行!超级简单,使用了 "unique函数" 。时间复杂度为O(n) 解法二:来自官方题解。维护两个指针,i是慢指针,j是快指针。 ...
分类:
其他好文 时间:
2019-02-02 14:29:11
阅读次数:
173
传送门:点我 You have an array of logs. Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifie ...
分类:
其他好文 时间:
2019-01-26 23:46:19
阅读次数:
348
题目说明 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。 解法1 时间复杂度:O(n) 空间复杂度:O(1) 思路:利用数组为有序数组这一条件。使用双指针, ...
分类:
其他好文 时间:
2019-01-26 11:19:09
阅读次数:
181
题目说明 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素最多出现两次,返回移除后数组的新长度。 解法1 时间复杂度:O(n) 空间复杂度:O(1) 思路:使用双指针,第一个指针j表示调整后的数组最后一个位置,第二个指针i遍历原数组。 当nums[i]与nums[j]不等时,直接添加即 ...
分类:
其他好文 时间:
2019-01-26 10:56:40
阅读次数:
198