class Solution {
public:
bool wordBreak(string s, unordered_set &dict){
int len = s.length();
vector match(len + 1, false);
match[0] = true;
for (int i = 1; i <= len; i++){
for (int k = 0;...
分类:
其他好文 时间:
2014-09-01 22:49:03
阅读次数:
273
题目链接:点击打开链接
题意:
给定n*m的矩阵
# 是墙 . 和字母是平地
最多有26个字母(不重复出现)
下面k个指令,
每个指令代表移动的方向和步数。
若以某个字母为起点,依次执行所有的指令,任何过程都不会撞到墙或走出地图,则这个字母合法。
按字典序输出所有合法的字母。若没有字母合法则输出' no solution'
预处理一下前缀和然后暴力。
#include ...
分类:
其他好文 时间:
2014-09-01 19:39:13
阅读次数:
239
我只能想出二分的方法,而且还不一定能写出最简洁的代码。无论刷多少遍,牛顿迭代法我都想不到,莫名有种悲哀的感觉:智力是硬伤啊。就算如此,却还要一遍遍不厌其烦地刷,这才是最悲剧的。多说无益,上代码。 二分:class Solution {public: int sqrt(int x) { ...
分类:
其他好文 时间:
2014-09-01 17:18:13
阅读次数:
144
问题描述
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
解决方案public class Solution {
public String reverseWord...
分类:
其他好文 时间:
2014-08-31 23:04:42
阅读次数:
232
#include
#include
#include
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
bool hasCycle(ListNod...
分类:
其他好文 时间:
2014-08-31 23:04:12
阅读次数:
287
必须选择下面的基本模式:Query, Verify, Signature Check, Install/Upgrade/Freshen, Uninstall, Initialize Database, Rebuild Database, Resign, Add Signature, Set Owne...
分类:
系统相关 时间:
2014-08-31 13:11:31
阅读次数:
278
Axure Axure RP是一个专业的快速原型设计工具。 代表美国Axure公司;RP则是Rapid Prototyping(快速原型)的缩写。 美国Axure Software Solution公司旗舰产品。 Axure RP的使用者主要包括 : 商业分析师、信息架构师、可用性专家...
分类:
其他好文 时间:
2014-08-31 13:08:31
阅读次数:
215
1 class Solution { 2 public: 3 double findMedianSortedArrays(int A[], int m, int B[], int n) { 4 vector v(m+n); 5 for(int i=0;i<m...
分类:
其他好文 时间:
2014-08-31 10:23:01
阅读次数:
176
类似于2sum,先排序,然后从左开始遍历,计算a[i]后面的等于-a[i]的两个元素,注意去除重复元素 1 class Solution { 2 public: 3 vector > threeSum(vector &num) { 4 vector > res; 5 ...
分类:
其他好文 时间:
2014-08-30 23:00:40
阅读次数:
292
题意: 给出最多5个序列,问这几个序列的最长公共子序列的长度是多少。solution : 脑抽级别我是,第一个序列每个数字位置固定,这样只要维护一个k-1维的偏序集就好了。然后在保证每个位置合法的情况下走一遍最长上升子序列就好了。1#include2usingnamespacestd;3consti...
分类:
其他好文 时间:
2014-08-30 21:33:20
阅读次数:
173