a*e
2 楼
https://leetcode.com/problems/word-ladder/
如果也不用其他的如map一类来标记是否已经访问过某个词,有人只用一个queue搞定吗?
class Solution {
public:
int ladderLength(string start, string end, unordered_set &dict) {
int ns=start.size(), ne=end.size();
if (ns==0&&ne==0) return 0;
queue q;
string mid;
q.push(start);
int c=1, find=0;
while(q.empty()!=true)
{
start=q.front();
q.pop();
if ( start==end)
{
find=1;
break;
}
for(int i=0; i {
mid=start;
for (int j=0; j<26; j++)
{
char tc = 'a'+j;
if (mid[i]!=tc)
{
mid[i]=tc;
if (dict.find(mid)!=dict.end())
{
q.push(mid);
dict.erase(mid);
c++;
if ( mid==end)
return c;
}
else
continue;
}
}
}
}
if (find)
return c;
else
return 0;
}
};
如果也不用其他的如map一类来标记是否已经访问过某个词,有人只用一个queue搞定吗?
class Solution {
public:
int ladderLength(string start, string end, unordered_set
int ns=start.size(), ne=end.size();
if (ns==0&&ne==0) return 0;
queue
string mid;
q.push(start);
int c=1, find=0;
while(q.empty()!=true)
{
start=q.front();
q.pop();
if ( start==end)
{
find=1;
break;
}
for(int i=0; i
mid=start;
for (int j=0; j<26; j++)
{
char tc = 'a'+j;
if (mid[i]!=tc)
{
mid[i]=tc;
if (dict.find(mid)!=dict.end())
{
q.push(mid);
dict.erase(mid);
c++;
if ( mid==end)
return c;
}
else
continue;
}
}
}
}
if (find)
return c;
else
return 0;
}
};
b*s
3 楼
【 以下文字转载自 NextGeneration 讨论区 】
发信人: babykittens (嘎嘎), 信区: NextGeneration
标 题: 为老妈寻找一起旅游的同伴
发信站: BBS 未名空间站 (Sun Jun 29 01:11:34 2014, 美东)
老妈一个人,想去阿拉斯加和加拿大玩,寻找同性玩伴,有兴趣的同学请发站内信联系
,谢谢!
去阿拉斯加是乘坐从三藩出发的游轮,往返11天。游轮信息请看二楼链接。
去加拿大是跟旅游团,详细信息请看二楼链接。
FYI:乘坐游轮需要加拿大旅行签证或者绿卡。
谢谢!
发信人: babykittens (嘎嘎), 信区: NextGeneration
标 题: 为老妈寻找一起旅游的同伴
发信站: BBS 未名空间站 (Sun Jun 29 01:11:34 2014, 美东)
老妈一个人,想去阿拉斯加和加拿大玩,寻找同性玩伴,有兴趣的同学请发站内信联系
,谢谢!
去阿拉斯加是乘坐从三藩出发的游轮,往返11天。游轮信息请看二楼链接。
去加拿大是跟旅游团,详细信息请看二楼链接。
FYI:乘坐游轮需要加拿大旅行签证或者绿卡。
谢谢!
p*g
5 楼
1是可以的, 2好象不行
b*s
6 楼
去阿拉斯加是乘坐从三藩出发的游轮,往返11天。游轮信息请看以下链接:
http://cruise.expedia.com/Search5.aspx?ds=Alaska&dp=San+Francis
去加拿大是跟旅游团,详细信息请看以下链接:
http://lassentours.net/product.aspx?id=151
http://cruise.expedia.com/Search5.aspx?ds=Alaska&dp=San+Francis
去加拿大是跟旅游团,详细信息请看以下链接:
http://lassentours.net/product.aspx?id=151
f*p
8 楼
还以为是征婚呢
M*O
10 楼
这个是和年龄成反比的。。。
D*3
13 楼
什么叫交公粮
相关阅读
LA shelter 统计资料,看有多少被领养,多少没有总有那样的宠物 在我需要的时候陪伴左右我看Sadie感冒是快好了,才把她本性显露出来因为小布他爹,我们的狗打架了猫在外打架受伤了,求助!!!!!!!!!!!!!!木兰病了 :(PetFoodDirect 20% coupon送一只可爱至极的小猫咪,谁要?大家狗狗平时早上睡到几点起视频,笑翻了,猫舔狗但是.....从国内带狗出来,在哪办手续啊?想看bull dog 请近来,看看这个Snicker化妆照一只猫坚决要吃素喜欢看经书凯的新年照狗小乐吃药视频陪陪19磅多了请教——Ulf是aggressive吗?新年了请大家联署签名 取消养熊立案 !!!