Redian新闻
>
motorola citrus上可以装alf的测光表么?
avatar
motorola citrus上可以装alf的测光表么?# PhotoGear - 摄影器材
J*9
1
Problem at
http://discuss.leetcode.com/questions/765/word-break
This does not seem to be a DP problem, just do it in a straightforward way.
Here's my implementation in C. Any issue?
Thanks.
//===========================================================
#include
#include
#include
#include
#include
/**
* Given a string s and a dictionary of words dict, determine if s can be
segmented into a space-separated sequence of one or more
* dictionary words.
*
* For example, given
* s = "leetcode",
* dict = ["leet", "code"].
*
* Return true because "leetcode" can be segmented as "leet code".
*/
void stringGetSubstr(const char *word, char *substr, int start, int end)
{
if (!word || !substr)
return;
char *d = substr;
for(int i=start; i*d++ = word[i];
*d = '\0';
printf("%s(): substr=%s\n", __FUNCTION__, substr);
}
bool stringDictContains(const char *substr, const char *dict[])
{
if (!substr)
return true;
if (!dict)
return false;
int i=0;
while(dict[i])
{
if (!strcmp(dict[i], substr))
return true;
i++;
}
return false;
}
bool stringWordBreakable(const char *word, const char *dict[])
{
if (!word || !dict)
return false;
int len = strlen(word);
char substr[len+1];
char substr2[len+1];
if (stringDictContains(word, dict))
return true;
for(int i=1; i{
stringGetSubstr(word, substr, 0, i);
if (stringDictContains(substr, dict))
{
stringGetSubstr(word, substr2, i, len);
if (stringDictContains(substr2, dict))
{
printf("Got it: %s %s\n", substr, substr2);
return true;
}
}
}
return false;
}
int main (int argc, char *argv[])
{
const char *word = "leetcode";
const char *dict[] = { "leet", "code", NULL};
if (stringWordBreakable(word, dict))
printf("breakable:YES\n");
else
printf("breakable:NO\n");
const char *word2 = "leetscode";
if (stringWordBreakable(word2, dict))
printf("breakable:YES\n");
else
printf("breakable:NO\n");
return 0;
}
/**
* stringGetSubstr(): substr=l
* stringGetSubstr(): substr=le
* stringGetSubstr(): substr=lee
* stringGetSubstr(): substr=leet
* stringGetSubstr(): substr=code
* Got it: leet code
* breakable:YES
* stringGetSubstr(): substr=l
* stringGetSubstr(): substr=le
* stringGetSubstr(): substr=lee
* stringGetSubstr(): substr=leet
* stringGetSubstr(): substr=scode
* stringGetSubstr(): substr=leets
* stringGetSubstr(): substr=leetsc
* stringGetSubstr(): substr=leetsco
* stringGetSubstr(): substr=leetscod
* breakable:NO
*
*/
avatar
e*1
2
三月份申请的,本来想着催一下,因为summer有门课需要教。没想到那个接线员给我加
急了,然后就收到邮件说是你被security check了,然后需要等回复。。一直到现在都
没有回音。学校summer的课也是基本上黄了。。不知道fall 之前能不能转下来。如果
转不下来fall的课也 黄了。。。大家说我现在应该怎么办呢?有没有什么催的办法没
有呢?给点建议好吗?非常感谢。发包子!!!!!
avatar
G*d
3
ruti
avatar
s*u
4
Of course it can be done by DP.Or, actually it;s slightly better to do with
recursion + memorization for some cases.
for example: "leetleet", for bottom-up dp, you need to judge "leet" twice
avatar
e*1
5
tititititi
avatar
a*f
6
should be okay. just don't count on the lightmeter function (use the manual
light scenario selection)
avatar
a*r
7
让学校办H1B吧!

【在 e********1 的大作中提到】
: 三月份申请的,本来想着催一下,因为summer有门课需要教。没想到那个接线员给我加
: 急了,然后就收到邮件说是你被security check了,然后需要等回复。。一直到现在都
: 没有回音。学校summer的课也是基本上黄了。。不知道fall 之前能不能转下来。如果
: 转不下来fall的课也 黄了。。。大家说我现在应该怎么办呢?有没有什么催的办法没
: 有呢?给点建议好吗?非常感谢。发包子!!!!!

avatar
e*1
8
学校不给办没办法。不知道这大概要等多久啊,security check

【在 a****r 的大作中提到】
: 让学校办H1B吧!
avatar
e*1
9
踢踢,谁知道现在security check要多久啊?

【在 e********1 的大作中提到】
: 学校不给办没办法。不知道这大概要等多久啊,security check
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。