随笔分类 - LeetCode
摘要:题目链接Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2]....
阅读全文
摘要:题目链接Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.分析:首先要注意的是,输入数组中可能有重复的点。由于两点确定一条直线,一个很直观的解法是计算每两个...
阅读全文
摘要:其他LeetCode题目欢迎访问:LeetCode结题报告索引LeetCode:Word LadderGiven two words (startandend), and a dictionary, find the length of shortest transformation sequenc...
阅读全文
摘要:题目链接Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identica...
阅读全文
摘要:题目链接Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 /...
阅读全文
摘要:LeetCode:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You...
阅读全文
摘要:LeetCode:Binary Tree Level Order TraversalGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by ...
阅读全文
摘要:题目链接Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level an...
阅读全文
摘要:LeetCode:Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST分析:...
阅读全文
摘要:题目链接Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the d...
阅读全文
摘要:LeetCode:Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from...
阅读全文
摘要:LeetCode:Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals...
阅读全文
摘要:题目链接Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flatten...
阅读全文
摘要:我的LeetCode解题报告索引题目链接Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is ...
阅读全文
摘要:LeetCode:Populating Next Right Pointers in Each NodeGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; ...
阅读全文
摘要:LeetCode:Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1...
阅读全文
摘要:题目链接Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the...
阅读全文
摘要:LeetCode:Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted...
阅读全文
摘要:题目如下: 二叉树的最大路径和(题目链接)Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below bin...
阅读全文
摘要:最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考。根据我自己做的进度持续更新中...... 本文地址LeetCode:Reverse Words in a StringLeetCode:Evaluate Reverse Polish N...
阅读全文