上一页 1 2 3 4 5 6 ··· 22 下一页
摘要: Condition Variable The Bounded-Buffer problem, also known as the producer-consumer problem, can be easily solved using the semaphore. In C++, there ar 阅读全文
posted @ 2019-10-14 06:09 約束の空 阅读(562) 评论(0) 推荐(0) 编辑
摘要: Condition Variable is a kind Event used for signaling between 2 or more threads. One thread can wait for it to get signaled, while other thread can si 阅读全文
posted @ 2019-10-14 03:33 約束の空 阅读(333) 评论(0) 推荐(0) 编辑
摘要: Race Condition: A situation like this, where several processes access and manipulate the same data concurrently and the outcome of the execution depen 阅读全文
posted @ 2019-10-14 03:18 約束の空 阅读(484) 评论(0) 推荐(0) 编辑
摘要: Constructor C++11 提供了std::thread,std::thread thread_object(callable),callable可以是 1. A function pointer 2. A function object 3. A lambda expression To 阅读全文
posted @ 2019-10-14 00:23 約束の空 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Overview C++11 Multithreading - Create Threads C++11 Multithreading - Mutex Lock C++11 Multithreading - Condition Variable C++11 Multithreading - Sema 阅读全文
posted @ 2019-10-13 23:16 約束の空 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Node *insert / delete (Node *root, int key) 通过返回 Node * 来insert和delete。注意都要 root = insert / delete (root, key),否则bst为空insert第一个元素,或者删除掉最后一个元素的时候,root指 阅读全文
posted @ 2019-10-12 13:49 約束の空 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 57. Insert Interval 由于intervals已经有序,不需要排序。本题是要返回一个interval数组,所以并不需要对原数组进行改动。 方法一: 由于intervals有序,我们可以二分找到应该插入的位置,然后merge intervals即可。 时间复杂度 O(n) 方法二: 我 阅读全文
posted @ 2019-10-12 05:00 約束の空 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 经典backtracing的问题。我们可以记录每行,每列,每个box那些数字出现过,快速判断当前填入的数字是否有重复。 上述方法是dfs(i,j),导致没到一行的末尾要换行,比较繁琐。 可以把所有空格都放到一个vector里,dfs这个vector的下标即可。 阅读全文
posted @ 2019-09-30 23:57 約束の空 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Recursive 对于s的每一个节点,我们都要调用isSame来判断两棵树是否相同。 时间复杂度 O(mn) PreOrder + Serialize 本质就是用preOrder来serialize两个树。如果t是子树,那么序列化之后,t一定是s的字串。 假设concatenate长度为n的字符串 阅读全文
posted @ 2019-09-27 11:07 約束の空 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Sliding Window (fixed length) 比较straightforward的方法,用长度为p的window去扫描,判断两个hashtable统计结果是否相同。在不清楚C++里unordered_map有没有重载==的情况写,可以用两个vector来做counter。 Slidin 阅读全文
posted @ 2019-09-26 08:56 約束の空 阅读(139) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 22 下一页