题目:与版本一不同的是,这里给定了一个矩阵,矩阵中元素为0的点表示该点可达,为1的点表示不可达,当然,不可达也就意味着不可经过。以左上角为出发点,右下角为目标终点,可行的不同路径有多少。
分析:
在Uniqu Paths I 的基础上,加上对矩阵可达性的判断就可以了。
注意:
1.左上角的元素是1的时候,即出发点就不可达,即出发不了,倒在了起跑线上。
2.给定的矩阵是1*1的形式。
3...
分类:
其他好文 时间:
2014-05-26 05:48:24
阅读次数:
247
function Animal(name) {
this.name = name;
}
Animal.prototype.eat = function(food) {
console.log("food");
};
Animal.prototype.getName = function()
{
return this.name;
};
var a = new An...
分类:
Web程序 时间:
2014-05-26 05:21:44
阅读次数:
345
题目:实现linux C下常用的字符串操作函数
题目分析:
一、面试中可能经常遇到这样的问题:比如strcpy、memcpy、strstr
二、参考了linux 内核代码,对linux大神表示感谢,代码写得相当精致,这里拿来与大家分享吧
算法实现:
/*
* linux/lib/string.c
*
* Copyright (C) 1991, 1992 Lin...
分类:
系统相关 时间:
2014-05-26 05:21:03
阅读次数:
474
【题目】
Implement pow(x, n).
【题意】
实现pow(x, n)
【思路】
最直接的思路是用一个循环,乘n次的x。
当n的值较小的时候还好,当n非常大时,时间成本就非常高。加入n=INT_MAX, 也就是21亿多次循环,你可以试想一下。
在这种情况下,我们需要快速的乘完n个x,采用尝试贪心的方法,即滚雪球方式的翻倍相乘
注意:几种特殊情况
1. n=0;
2. n<0;...
分类:
其他好文 时间:
2014-05-26 04:37:31
阅读次数:
212
题目虽然有点多,但是都是最常见的面试题。如果大家准备参加相关的面试,最好看看。尤其最后的几十个跨国公司面试题。现在国内很多企业都开始学习这套方式,来为难大家。有准备,就容易成功。
即使大家今年不打算找工作,也可以作为一个水平考察,看看自己到底可以应对多少。
面试题1 介绍ASP.NET
答:asp.net是建立在通用语言运行库的程序架构,通过asp.net可以开发出非常强大的Web...
分类:
Web程序 时间:
2014-05-26 03:59:09
阅读次数:
409
【题目】
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
【题意】
解N皇后问题,N-Queens要求返回所有的解,而本题只需要返回可行解的数目
【思路】
DFS,参考N-Queens...
分类:
其他好文 时间:
2014-05-25 01:51:55
阅读次数:
236
装饰者模式(Decorator Pattern) Java的IO类 使用方法
本文地址: http://blog.csdn.net/caroline_wendy/article/details/26716823
装饰者模式(decorator pattern)参见: http://blog.csdn.net/caroline_wendy/article/details/2670...
分类:
编程语言 时间:
2014-05-25 00:55:05
阅读次数:
346
int cnt = 0;
while(1) {
++cnt;
ptr = (char *)malloc(1024*1024*128);
if(ptr == NULL) {
printf("%s\n", "is null");
break;
}
}
printf("%d\n", cnt);
这个程序会有怎样的输出呢?...
分类:
系统相关 时间:
2014-05-24 21:59:47
阅读次数:
479
装饰者模式(Decorator Pattern) 详解
本文地址: http://blog.csdn.net/caroline_wendy
装饰者模式(Decorator Pattern):
动态地将责任附加到对象上. 若要扩展功能, 装饰者提供了比继承更有弹性的替代方案.
使用方法:
1. 首先创建组件(Component)父类, 所有类,
具体组件(...
分类:
其他好文 时间:
2014-05-24 20:45:41
阅读次数:
317
【题目】
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