随笔分类 - Heap/ Graph
摘要:break the loop at the last node which pointed to the entry. Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove
阅读全文
摘要:Taken from GeeksforGeeks Following is a simple algorithm to find out whether a given graph is Birpartite or not using Breadth First Search (BFS) :- Al
阅读全文
摘要:Heap的介绍1,介绍2,要注意complete tree和full tree的区别, Heap是complete tree;Heap里面 i 的 children分别是 i*2+1 和 i*2+2,i 的 parent是 (i-1)/2 Heapify的基本思路就是:Given an array
阅读全文
摘要:类似于find kth small element in sorted matrix, 另外数组是个好东西,在构造heap 的元素的时候 Some observations: For every numbers in nums1, its best partner(yields min sum) a
阅读全文
摘要:Analysis: Solution 1: The greedy algorithm is that in each step, select the char with highest remaining count if possible (if it is not in the waiting
阅读全文
摘要:方法1:Time Complexity O(NK) 暂时只有两个Heap的做法,缺点:In this problem, it is necessary to be able remove elements that are not necessarily at the top of the heap
阅读全文
摘要:Example 2: Example 3: The logic is very similar to NO.347 and here we just use a map a count and according to the frequency to put it into the right b
阅读全文
摘要:容器此处还可以用 hashMap, 其中set既可以表示里面的边又可以表示入度数, 但是此处只需要知道入度数就可以了. 之前还有用 int [] ArrayList[] 来表示的同set, 因为坐标可以表示map中的键, 容器内元素可以表示值.
阅读全文
摘要:感悟: 遍历图上的点先想到宽度优先搜索, 有很多模板 5.9: 图、节点 adj.get(edge[0]).add(edge[1]); adj.get(edge[1]).add(edge[0]); }), set的size==1当作叶节点的判断标准.加入节点存储器list中, 用while-loop
阅读全文
摘要:Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to
阅读全文
摘要:Graph, DFS (1) Build the map, the key is dividend, the value is also a map whose key is divisor and value is its parameter. For example, a / b = 2.0,
阅读全文

浙公网安备 33010602011771号