#include #include #ifdef __linux
#include #endif
// MINIMUM(A)
// MIN = A[1]
// for i = 2 to A.length
// if min > A[i]
// min = A[i]
// return min int...
分类:
编程语言 时间:
2015-02-09 21:26:03
阅读次数:
373
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA...
Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo...
分类:
其他好文 时间:
2015-02-09 15:33:25
阅读次数:
165
Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol...
分类:
其他好文 时间:
2015-02-09 15:23:38
阅读次数:
103
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
push(x) – Push element x onto stack.
pop() – Removes the element on top of the stack.
top() –...
分类:
其他好文 时间:
2015-02-09 14:13:19
阅读次数:
157
题意为得出二叉树的最小深度,但深度是定义为从根节点到叶子节点的最少节点数。
容易出错的地方:为空节点时,直接返回0。这是不对的,要判断其是否有兄弟节点,没有兄弟节点的时候才能返回0,即这个节点的父节点是一个叶子节点。
错解1:
class Solution {
public:
int minDepth(TreeNode *root) {
if(root==nullptr)
...
分类:
其他好文 时间:
2015-02-09 12:58:55
阅读次数:
132
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m...
分类:
其他好文 时间:
2015-02-09 00:44:49
阅读次数:
135
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes...
分类:
其他好文 时间:
2015-02-09 00:43:38
阅读次数:
237
Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort...
分类:
其他好文 时间:
2015-02-09 00:37:00
阅读次数:
166
You are given n integers. Your task is very easy. You should find the maximum integer a and the minimum integer b among these n integers.
And then you should replace both a and bwith a-b. Your task ...
分类:
其他好文 时间:
2015-02-08 15:34:12
阅读次数:
165