leetcode
想看焰火吗
这个作者很懒,什么都没留下…
展开
-
Unique Binary Search Trees (6行代码 dp)
https://discuss.leetcode.com/topic/8398/dp-solution-in-6-lines-with-explanation-f-i-n-g-i-1-g-n-i/2转载 2016-11-04 09:07:17 · 333 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The pa原创 2016-11-17 08:55:24 · 485 阅读 · 0 评论 -
Minimum Moves to Equal Array Elements I&&II
第一个问题:Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Inpu原创 2016-11-20 19:44:25 · 347 阅读 · 0 评论 -
207. Course Schedule 广度优先&&拓扑排序
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a原创 2016-12-28 08:32:48 · 445 阅读 · 0 评论 -
208. Implement Trie (Prefix Tree) 前缀树的实现
implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.class TrieNode {public: bool isKey; TrieNode* child转载 2016-12-30 21:28:50 · 400 阅读 · 0 评论 -
寻找多数元素
在原序列中去除两个不同的元素后,那么在原序列中的多数元素在新序列中还是多数元素算法基本思路:(1)在寻找多数元素的过程中,将计数器置1,遇到相同元素则计数器加1,遇到不同元素则计数器减1,一直到计数器等于0或遍历完整个序列。由此可见,计数器的值表示当前元素抵消掉不同元素后的出现次数;(2)当计数器在遍历完整个序列前就已经是0,则忽略掉已经遍历过的元素(可以看作两两抵消不转载 2017-04-23 11:38:45 · 715 阅读 · 0 评论