题目链接简单递推附上代码: 1 class Solution { 2 public: 3 int
climbStairs(int n) { 4 int f0 = 1, f1 = 1, f2 = 1; 5 for (int i = 2; i <= n;
i++)...
分类:
其他好文 时间:
2014-05-29 01:48:48
阅读次数:
175
题目链接从代码的健壮性考虑,
应该顾及到把数字翻转后发生溢出的情况,但是此题中并没有这种测试数据。附上代码: 1 class Solution { 2 public: 3 int
reverse(int x) { 4 int tmp = abs(x); 5 i...
分类:
其他好文 时间:
2014-05-29 00:26:22
阅读次数:
243
class Solution { public: vector
spiralOrder(vector > &matrix) { vector ret; int cols = 0; ...
分类:
其他好文 时间:
2014-05-28 14:38:02
阅读次数:
236
题目链接题意: find the maximum positive difference
between the price on the ith day and the jth day附上代码: 1 class Solution { 2
public: 3 int maxProfit(ve...
分类:
其他好文 时间:
2014-05-28 03:49:45
阅读次数:
307
mysql占用内存太大,所以选用sqlite安装://更新sudo apt-get
updatesudo apt-get upgrade//安装nginxsudo apt-get install nginx//启动nginxsudo
/etc/init.d/nginx start//安装php-fp...
分类:
数据库 时间:
2014-05-28 01:24:21
阅读次数:
379
Reverse Words in a String反转一个字符串垃圾方法:#include
#include class Solution {public: void reverseWords(string &s) {
istringstream is(s); st...
分类:
其他好文 时间:
2014-05-26 13:39:16
阅读次数:
271
这种题都采用倒序的方式吧,从大到小添加。要注意的是一些小细节:比如for(int i = m+n-1;
i >=0; i--){}, 在for语句里面已经有i--了,循环里面就不需要再写一个i--了 1 public class Solution { 2
public void merge(...
分类:
其他好文 时间:
2014-05-26 12:14:48
阅读次数:
227
Implementint sqrt(int x).Compute and return the
square root ofx.思路:二分查找法解决这道题class Solution {public: int sqrt(int x) { if(x1e-6)
{ ...
分类:
其他好文 时间:
2014-05-25 19:35:33
阅读次数:
225
【题目】
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens puzzle.
Each solution contains a distinct board configuratio...
分类:
其他好文 时间:
2014-05-24 17:12:32
阅读次数:
237
自定义的tabbaritem图片比系统的高出一截来Solution:self.tabbar.tabBar.layer.masksToBounds=YES;//边界隐藏但是由于设置masksToBounds属性为true所以Layer的阴影效果也就没有了
分类:
其他好文 时间:
2014-05-24 15:32:32
阅读次数:
179