上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 28 下一页
摘要: Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c 阅读全文
posted @ 2017-11-13 00:55 apanda009 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo 阅读全文
posted @ 2017-11-09 05:12 apanda009 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: 类似于find kth small element in sorted matrix, 另外数组是个好东西,在构造heap 的元素的时候 Some observations: For every numbers in nums1, its best partner(yields min sum) a 阅读全文
posted @ 2017-11-07 22:41 apanda009 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-11-07 21:37 apanda009 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 方法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 阅读全文
posted @ 2017-11-07 12:24 apanda009 阅读(145) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 28 下一页