随笔分类 -  leetcode

摘要:class Solution { public: vector<int> pre; unordered_map<int,int> v; TreeNode* f(int root_pre_index,int l,int r){ if(l>r) return nullptr; int i=v[pre[r 阅读全文
posted @ 2021-02-09 21:30 aaaaassss 阅读(27) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/interval-list-intersections/ class Solution { public: vector<vector<int>> intervalIntersection(vector<vector<int>>& A 阅读全文
posted @ 2020-09-30 21:24 aaaaassss 阅读(91) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/find-mode-in-binary-search-tree/ class Solution { public: int count = 0, max_count = 0; TreeNode* pre = NULL; vector< 阅读全文
posted @ 2020-09-24 17:09 aaaaassss 阅读(86) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/redundant-connection-ii/ 对于有向图的树,如果增加一条有向边,则会出现两种情况 第一种为形成一个点有两个father 1.有有向环,无环 第二种为有环 class Solution { private: sta 阅读全文
posted @ 2020-09-17 22:32 aaaaassss 阅读(99) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/number-of-longest-increasing-subsequence/solution/c-dong-tai-gui-hua-by-da-li-wang-18/ class Solution { public: int f 阅读全文
posted @ 2020-09-17 21:10 aaaaassss 阅读(86) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/house-robber-iii/solution/da-jia-jie-she-iii-by-leetcode-solution/ class Solution { public: unordered_map <TreeNode*, 阅读全文
posted @ 2020-08-05 22:04 aaaaassss 阅读(57) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/increasing-triplet-subsequence/ https://leetcode-cn.com/problems/increasing-triplet-subsequence/solution/c-z-by-zrita 阅读全文
posted @ 2020-07-28 22:21 aaaaassss 阅读(66) 评论(0) 推荐(0)
摘要:https://leetcode-cn.com/problems/contains-duplicate-iii/ https://leetcode-cn.com/problems/contains-duplicate-iii/solution/cjian-ji-dai-ma-by-orangeman 阅读全文
posted @ 2020-07-28 21:59 aaaaassss 阅读(71) 评论(0) 推荐(0)
摘要:利用二分图没有奇环的性质 DFS: class Solution { private: static constexpr int UNCOLORED = 0; static constexpr int RED = 1; static constexpr int GREEN = 2; vector<i 阅读全文
posted @ 2020-07-16 19:13 aaaaassss 阅读(73) 评论(0) 推荐(0)
摘要:给定一个用字符数组表示的 CPU 需要执行的任务列表。其中包含使用大写的 A - Z 字母表示的26 种不同种类的任务。任务可以以任意顺序执行,并且每个任务都可以在 1 个单位时间内执行完。CPU 在任何一个单位时间内都可以执行一个任务,或者在待命状态。 然而,两个相同种类的任务之间必须有长度为 n 阅读全文
posted @ 2020-07-15 22:12 aaaaassss 阅读(110) 评论(0) 推荐(0)