- 浏览: 1682245 次
- 性别:
- 来自: 北京
最新评论
-
nucleus:
貌似是因为图片的路径是http的缘故:http://dl2.i ...
spring container 实现分析:BeanWrapper -
nucleus:
nucleus 写道BeanWrapper这一块相关的类结构如 ...
spring container 实现分析:BeanWrapper -
nucleus:
BeanWrapper这一块相关的类结构如下图:文中提到的上述 ...
spring container 实现分析:BeanWrapper -
leshy:
inventory.sort(Comparator.compa ...
java8 lambda表达式学习总结 -
Leisurez:
di1984HIT 写道xuexile~hahaha~
activemq的几种基本通信方式总结
文章列表
问题描述:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
Note:You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy a ...
问题描述:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple tran ...
问题描述:
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Example 1:
Input: [7, 1, 5, 3, ...
问题描述:
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 following triangle
[
[2],
[3,4],
[6,5,7],
[4,1,8,3]
]
The minimum path sum from top to bottom is 11 (i.e ...
问题描述:
Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,Return [1,3,3,1].
Note:Could you optimize your algorithm to use only O(k) extra space?
原问题链接:https://leetcode.com/problems/pascals-triangle-ii/
问题分析
从 ...
问题描述:
Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
原问题链接:https://leetcode.com/problems/pascals-triangle/
问题分析
这个问题的思路需要一点时间来考虑。在针对一些特殊情况的考虑来说,我们首先要考虑numRows小于1的情况。 ...
问题描述:
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra space.
For example,Given the following binary tree,
1
/ \ ...
问题描述:
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all ne ...
问题描述:
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i ...
问题描述:
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:Given the below binary tree and sum = 22,
5
/ \
4 8
/ / \
11 13 4
/ \ / \
...
问题描述:
Given 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 the given sum.
For example:Given the below binary tree and sum = 22,
5
/ \
4 8
/ / \
...
问题描述:
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.
原问题链接:https://leetcode.com/problems/minimum-depth-of-binary-tree/
问题分析
粗看起来,这个问题比较简单,因为要求的是二叉树的最短长度,那么只要找到它到叶节点的最近的距离就可以了。而这 ...
问题描述:
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 depth of the two subtrees of every node never differ by more than 1.
原问题链接:https://leetcode.com/problems/balanced-binary-tree/
问题分析
这个问题的 ...
问题描述:
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
原问题链接:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/
问题分析
这个问题和前面的问题有点不一样,它的输入不是一个array,而是一个链表。那么,这个时候如果还是按照前面一个个遍历过去找位置然后设置节点的话,效率会很低。因此需要做一些调整。
...
问题描述:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
原问题链接:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
问题分析
因为这里要求将排序后的数组转换成高度平衡的二叉搜索树,所以这里转换的时候,每次取的元素节点必须要尽量保证它的左右子树的元素个数是一样的。只有这样才能达到一个尽量平衡的结果。于是我们可以每次去数组中给定范围 ...