
leetcode
snowy19130140
这个作者很懒,什么都没留下…
展开
-
【LeetCode】442. Find All Duplicates in an Array 找出数组中所有重复项
题目: Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Request: (1) Find all the elements that appear twice in this array. (2)Could you ...原创 2018-10-07 18:38:25 · 252 阅读 · 0 评论 -
【LeetCode】 96. Unique Binary Search Trees
分析问题 分析题意,二叉搜索树的不同的原因在于数组中所有的元素均可以成为祖先节点,因此 第一步: 遍历数组,使得每一个元素都可以成为祖先节点。 第二步,确定好祖先节点之后,数组中的剩余n-1个数就会被分成两拨,左子树由小于祖先节点的数组成,有节点由大于祖先节点的数组成 当祖先节点值为 iii 时,左子树最大的数为 i−1i -1i−1, 于是左子树的元素个数可以从0增加到 i−1i - 1...原创 2018-09-28 11:18:09 · 335 阅读 · 0 评论 -
【LeetCode】322. Coin Change 硬币找零
题目: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of ...原创 2018-10-18 16:28:44 · 662 阅读 · 0 评论 -
【LeetCode】873. Length of Longest Fibonacci Subsequence 最长的斐波那契子序列的长度
题目 A sequence X1,X2,...,XnX_1, X_2, ..., X_nX1,X2,...,Xn is fibonacci-like if: n≥3n \ge 3n≥3 Xi+Xi+1=Xi+2 for all i+2≤nX_i + X_{i+1} = X_{i+2} \ \ for\ \ all\ ...原创 2018-12-24 16:38:56 · 296 阅读 · 0 评论