- 博客(12)
- 资源 (3)
- 收藏
- 关注
原创 817. Linked List Components
Description:We are given head, the head node of a linked list containing unique integer values.We are also given the list G, a subset of the values in the linked list.Return the number of connected components in G, where two values are connected if they
2020-05-27 10:45:12 147
转载 libevent中TAILQ_QUEUE队列的使用
https://blog.csdn.net/luotuo44/article/details/38374009
2020-05-20 17:38:48 160
原创 148. Sort List
Description:Sort a linked list in O(n log n) time using constant space complexity.Analysis:147是插入排序,时间复杂度O(N^2),这里要求O(n log n),快排满足要求。快排是用分治的思想,将链表分成两个子链表分别排序,然后再合并链表。Solution:class Solution {public: ListNode* sortList(ListNode* head) {
2020-05-18 12:19:31 110
原创 147. Insertion Sort List
Description:Sort a linked list using insertion sort.Analysis:插入排序,时间复杂度O(N^2)创建一个dummy node,方便从head开始遍历。可以结合题目148一起看。两种解法:解法一:断开链表,分成两个链表,链表1是有序链表,链表2是待排序链表,依次将链表2中的元素插入到链表1的有序链表中;解法二:不断开链表,依次移动结点,移动结点后,依然保持链表不断开。Solution1:class Solution {publ
2020-05-18 10:42:02 234
原创 42. Trapping Rain Water
Description:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Analysis:1.直接的想法(not AC)找到一个“V”型区间,区间中间就是每个区间可以接的水。提交后,发现有case错误,原来这种解法相当于是贪心,没办法对求对全局的ca
2020-05-14 18:04:48 97
原创 56. Merge Intervals
Description:Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].Example 2:Input: [[1
2020-05-12 21:03:55 109
原创 986. Interval List Intersections
Description:Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order.Return the intersection of these two interval lists.(Formally, a closed interval [a, b] (with a <= b) denotes the set of real numbers x w
2020-05-12 17:16:27 165
原创 78. Subsets
Description:Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Analysis:解法1:分治思想,复杂问题化成简单的子问题,子集i是子集i-1,然后加上nums[i]构成的集合。全排列、全组合、子集可以归纳为一类问题。Solution1:时间复杂度O
2020-05-08 23:27:51 106
原创 236. Lowest Common Ancestor of a Binary Tree
Description:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.Analysis:第一种:很直接的解法公共祖先,所以从根到结点的path前面部分相同,有些类似两个链表的公共结点,先求出root到结点的path,然后比较即可。第二种:参考很巧妙的解法...
2020-05-08 15:46:03 163
原创 145. Binary Tree Postorder Traversal
Description:Given a binary tree, return the postorder traversal of its nodes’ values.Analysis:递归解法容易,如果是非递归呢?很好解法:二叉树非递归解法决定这个解法的原因是二叉树的结构和依次访问二叉树的顺序,根-左-左-根-右-右-根。Solution1:两个辅助栈,输出栈是后序遍历的逆序,辅...
2020-05-08 11:26:10 122
原创 中心化副本
数据多个副本:选择中心化还是去中心化?中心化副本控制:副本有primary和secondary去中心化副本控制:所有副本地位相等问题1:主从节点更新1.主从节点之间数据的同步是同步模式还是异步模式?2.数据的流向?元数据和数据如何在主从之间写入3.部分节点写入失败了怎么办?问题2:主从节点数据读取1.secondary节点是否支持读取?2.如果secondary节点支持读取,是...
2020-05-07 21:02:36 150
AWK程序设计语言翻译
2015-12-21
opencv1.0安装程序
2013-06-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人