![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
【leetcode】收集
文章平均质量分 68
逆袭的小菜鸡
这个作者很懒,什么都没留下…
展开
-
Restore IP Addresses
题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]原创 2014-04-16 15:24:26 · 441 阅读 · 0 评论 -
Minimum Depth of Binary Tree
题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.原创 2014-04-04 15:53:42 · 404 阅读 · 0 评论 -
Palindrome Partitioning II
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",原创 2014-04-01 14:49:48 · 422 阅读 · 0 评论 -
Path Sum II
题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.算法思想:递归原创 2014-04-03 22:57:19 · 429 阅读 · 0 评论 -
Binary Tree Postorder Traversal(迭代写法)
题目:Given a binary tree, return the postorder traversal of its nodes' values.算法思想:迭代求一个二插树的后序遍历,首先得从根结点找到后序遍历输出的第一个结点(称“最左节点”),而且必须将这个过程中的所有结点记录下来(因为不能从儿子结点找到父结点),由于后入先出,所以选择栈记录,大体过程如下面步骤:1.从根结点开原创 2014-04-02 22:08:51 · 594 阅读 · 0 评论 -
Binary Tree Preorder Traversal(迭代写法)
题目:Given a binary tree, return the preorder traversal of its nodes' values.算法思想:参见点击打开链接vector preorderTraversal(TreeNode *root) { TreeNode *p = root; stack record; vector r原创 2014-04-02 22:30:33 · 890 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
题目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).算法思想:1,首先想到的是递归,对于一个结点,将左子树和右子树返回的结果合并起来,再加上根结原创 2014-04-03 14:39:39 · 638 阅读 · 0 评论 -
Palindrome Partitioning
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return原创 2014-04-04 12:44:51 · 558 阅读 · 0 评论 -
Max Points on a Line
题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.函数接口:int maxPoints(vector &points) {}算法思想:先剔除点数组points中重复的点,然后从前两个点开始,构建一条直线,依次加入新的点,新加入的原创 2014-03-30 20:58:10 · 352 阅读 · 0 评论 -
Decode Ways
题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the t原创 2014-04-07 14:44:42 · 435 阅读 · 0 评论