文章
Binary Tree Preorder/Postorder Traversal
树的前序和后序遍历是树相关算法的基本。就不多加解释了,直接上代码。BinaryTreePreorderTraversal(https://leetcode.com/problems/binarytreepreordertraversal/)<pre<codej
July 算法习题 - 字符串 3 + Leetcode - Add Binary,Palindromic Substring
虽是读书笔记,但是如转载请注明出处http://segmentfault.com/blog/exploring/(http://segmentfault.com/blog/exploring/)..拒绝伸手复制党最长回文子串题目描述<bloc
Word Break I II@LeetCode
WordBreak(https://leetcode.com/problems/wordbreak/)递归,基本属于暴力求解。但是纯暴力应该是过不了的,参考网上的办法,增加了一个<codeunmatch</code集合,类型是<codeHashSet</code,用来存放
Copy List with Random Pointer@LeetCode
CopyListwithRandomPointer(https://leetcode.com/problems/copylistwithrandompointer/)节点中需要拷贝的两个引用是<codenext</code和<coderandom</code。
Candy@LeetCode
Candy(https://leetcode.com/problems/candy/)双向爬坡。从左到右爬一边,再从右到左爬一边。再累加所有值即可。<pre<codejava</code<codepublicclassSolution{publicin
Palindrome Partitioning I II@LeetCode
PalindromePartitioning(https://leetcode.com/problems/palindromepartitioning/)递归解法。遍历每一种组合情况,其实这样的解法并不是很高效,但是还是是可以顺利<codeAC</code。实现代码:
Longest Consecutive Sequence@LeetCode
LongestConsecutiveSequence(https://leetcode.com/problems/longestconsecutivesequence/)本题直观的解法就是排序之后遍历,但是题目要求只用<codeO(n)</code的复杂度,那么先排序显然
Binary Tree Maximum Path Sum@LeetCode
BinaryTreeMaximumPathSum(https://leetcode.com/problems/binarytreemaximumpathsum/)动态规划深度优先搜索。把大问题(求整棵树的路径最大值)拆分成小问题(每颗子树的路径最大值),递推公式为:
Populating Next Right Pointers in Each Node I II@LeetCode
PopulatingNextRightPointersinEachNodeI(https://leetcode.com/problems/populatingnextrightpointersineachnode/)树的广度优先搜索题。记录下每一层的节点总个
Distinct Subsequences@LeetCode
DistinctSubsequences(https://leetcode.com/problems/distinctsubsequences/)动态规划题。先用二维动态规划的思路解释下:设<codematch</code是动态规划表,其中<codematchij<
已加载文章中没有匹配内容,试试其他关键词或清空搜索。