摘要: Better Solution: DFS, but only scan all the matches once! If a match can not make the 1st edge, then we do not discard it, we try 2nd, 3rd, 4th edge 阅读全文
posted @ 2017-11-08 22:14 apanda009 阅读(158) 评论(0) 推荐(0) 编辑
摘要: DFS, my solution is to fill each edge of the square one by one. DFS to construct the 1st, then 2nd, then 3rd, then 4th. For each edge I scan all the m 阅读全文
posted @ 2017-11-08 12:26 apanda009 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Backtracking: time complexity O(N!) Use HashMap to store the initial debts of each person, negative means the person sends money to others, positive m 阅读全文
posted @ 2017-11-08 11:20 apanda009 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-11-08 03:14 apanda009 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-11-08 01:26 apanda009 阅读(340) 评论(0) 推荐(0) 编辑