问题描述:
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:
Y...
分类:
其他好文 时间:
2014-12-30 22:08:07
阅读次数:
178
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 这个是我的代码,但是超时 class Solut...
分类:
移动开发 时间:
2014-12-30 22:06:15
阅读次数:
169
Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Credits:Special thanks to@tsf...
分类:
其他好文 时间:
2014-12-30 22:01:42
阅读次数:
107
问题描述:
Given an integer n, return the number of trailing zeroes in
n!.
Note: Your solution should be in logarithmic time complexity.
基本思想
尾0的个数取决于5的个数。
代码:
int trailingZeroes(int n) { //...
分类:
其他好文 时间:
2014-12-30 20:43:23
阅读次数:
132
Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.只有2 * 5才会产生0只要计算出因子中2和5的个数取小的...
分类:
其他好文 时间:
2014-12-30 20:27:13
阅读次数:
169
Factorial Trailing ZeroesGiven an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.统计末尾...
分类:
其他好文 时间:
2014-12-30 18:37:19
阅读次数:
142
题目:
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Note:
Given m, n sati...
分类:
编程语言 时间:
2014-12-30 17:18:11
阅读次数:
239
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
给出树的中序和先序遍历 要求返回树 中序结果{1,2,5,4,3,6} 先序{4,2,1,5,3,6}根据先...
分类:
其他好文 时间:
2014-12-30 15:22:45
阅读次数:
176
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
还是重构树 与上一题相比 先序换成了后序 思路还是一样 代码如下:
public class S...
分类:
其他好文 时间:
2014-12-30 15:22:19
阅读次数:
153
Factorial Trailing ZeroesGiven an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Cred...
分类:
其他好文 时间:
2014-12-30 13:28:46
阅读次数:
141