摘要: 与83类似,不过需要注意去除连续的重复片段的情况,如2 2 3 3这种情况,以及【1,1】这种情况下最终的cur为NULL,因此不能再令cur=cur->next; 阅读全文
posted @ 2019-06-13 16:59 Joel_Wang 阅读(276) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* ... 阅读全文
posted @ 2019-06-13 16:48 Joel_Wang 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 优先队列容器,使用小顶堆排序;timeO(nlogn) spaceO(n) 阅读全文
posted @ 2019-06-13 16:35 Joel_Wang 阅读(173) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode... 阅读全文
posted @ 2019-06-13 16:04 Joel_Wang 阅读(104) 评论(0) 推荐(0) 编辑
摘要: time O(n) spaceO(n) 的方法: 还是借助哈希表,所有字母初始化为0,将t中出现的所有字母次数全都记录在哈希表里; 采用双指针,分别为一个头指针head,和尾指针tail。flag记录当前[head,tail)没有出现的字母的个数; 1. flag不为0时,更改s[tail]的哈希值 阅读全文
posted @ 2019-06-13 11:09 Joel_Wang 阅读(169) 评论(0) 推荐(0) 编辑