```
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class ... ...
分类:
其他好文 时间:
2019-04-09 12:32:43
阅读次数:
152
```
class Solution {
public: ListNode *deleteDuplicates(ListNode *head) { if (!head || !head->next) return head; ListNode *dummy = new ListNode(-1), *... ...
分类:
其他好文 时间:
2019-04-09 12:25:36
阅读次数:
95
分析: 这个题也见过,剑指offer,为了检测这个点,要分三步走: 先检测有环不,并检测环中任意节点; 再检测环中个数; 最后让一个指针先走一定步数,然后判断两个指针什么时候处于环的起点终点。 ...
分类:
其他好文 时间:
2019-04-08 11:56:55
阅读次数:
157
1. 原始题目 Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: 2. 题目理解 给定一个排序链表,删除所有重复的元素,使得 ...
分类:
其他好文 时间:
2019-04-05 12:14:40
阅读次数:
140
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra ...
分类:
其他好文 时间:
2019-04-03 12:22:28
阅读次数:
146
分析: 思路有,但是一开始不确认正不正确,但是举的例子告诉我这样想目前是对的,于是就写了。 值的注意的是,while(max_num<len-2 && prices[max_num]<prices[max_num+1]),这句话里以后一定要先把值的边界性判断放前面,不然max_num+1超出边界,会 ...
分类:
其他好文 时间:
2019-04-02 12:24:38
阅读次数:
142
分析: 这个算法时间复杂度,因为只是遍历两遍链表,理论上是O(n),为了得到链表长度多遍历一遍,想了半天也没有其他的路子,后来想想相比一点点挪应该是快的吧。 写的时候有两个关键地方第一时间都没想到,第一是新节点的计算,由于举得案例不全,也巧合,导致我一开始写的不对。第二是没注意到新的节点就是头结点的 ...
分类:
其他好文 时间:
2019-03-25 23:16:39
阅读次数:
174
分析: 今天散会早,忍不住又做了一道。和上个题异曲同工,但是这里需要初始化一下。 ...
分类:
其他好文 时间:
2019-03-25 22:02:00
阅读次数:
161
82. Remove Duplicates from Sorted List II Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from ...
分类:
Web程序 时间:
2019-03-23 00:36:00
阅读次数:
166
80. Remove Duplicates from Sorted Array II Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and r ...
分类:
Web程序 时间:
2019-03-23 00:30:26
阅读次数:
218