由买买提看人间百态

topics

全部话题 - 话题: string
首页 上页 1 2 3 4 5 6 7 8 9 10 (共10页)
D***y
发帖数: 693
1
来自主题: FleaMarket版 - [出售] home depot $[email protected] Lowes $[email protected]
up

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
D***y
发帖数: 693
2
来自主题: FleaMarket版 - [出售] home depot $[email protected] Lowes $[email protected]
up

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
D***y
发帖数: 693
3
来自主题: FleaMarket版 - [出售] home depot $[email protected] Lowes $[email protected]
up

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
D***y
发帖数: 693
4
来自主题: FleaMarket版 - [出售] home depot $[email protected] Lowes $[email protected]
up

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
c*****n
发帖数: 2433
5
来自主题: FleaMarket版 - [出售]老ID [出售] Sears/kmart [email protected] Saks $200 @0.90
二手交易风险自负!请自行验证是否合法和一手卡!:
Y
我想卖的物品:
老ID [出售] Sears/kmart [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
Dell [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getEl... 阅读全帖
y*****7
发帖数: 1555
6
来自主题: FleaMarket版 - [出售]Target GC [email protected]
二手交易风险自负!请自行验证是否合法和一手卡!:
y
我想卖的物品:
Target GC [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
单张面值:
300
可接受价格(必须明码标价!):
0.95
物品新旧要求:
New
邮寄方式要求:
code only. Or you choose you pay
买... 阅读全帖
y*****e
发帖数: 1472
7
来自主题: FleaMarket版 - [出售]Chase INK [email protected]
二手交易风险自负!请自行验证是否合法和一手卡!:
y
我想卖的物品:
Chase Ink [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
单张面值:
chase Ink [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getEle... 阅读全帖
d***k
发帖数: 3225
8
来自主题: FleaMarket版 - [出售]Chase INK [email protected]
您好
点数零卖吗
我只需要七千迈

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data... 阅读全帖
d*****x
发帖数: 4
9
来自主题: FleaMarket版 - [出售]UA (United Airline) E-Certificate $[email protected]
二手交易风险自负!请自行验证是否合法和一手卡!:
Y
我想卖的物品:
UA (United Airline) E-Certificate $[email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
good for US domestic travels only
单张面值:
$250 expiring 04/26... 阅读全帖
g****y
发帖数: 436
10
来自主题: JobHunting版 - string /File IO processing using C (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: ggplay (dfdsf), 信区: Programming
标 题: string /File IO processing using C
发信站: BBS 未名空间站 (Wed Jan 20 21:57:01 2010, 美东)
这两天在改一个用C写的处理文件IO和字符串的程序,遇到众多令人头疼的问题,靠着
google和自己的一些想法勉强解决了,但是效率不高,想请教一下这里的大侠:
1。从文件中读取一行,例如:
SR01.01 02 G\t-\t9908\t#@#@$@@#@#@@
现在想得到SR01.01 02 G, -, 9908这三个字符串。
首先想到用scanf("%s%s%s%*s",s1,s2,s3);
但是不工作,因为SR01.01 02 G中间有两个空格。
放狗发现了一个bstrlib.h,里面有一个bsplit,可以使用\t作为delimiter。但是太麻
烦了,所以自己写了一个getTokens。
后来发现c++ programming how to里面有一个写得很好的string类,但是我
m******9
发帖数: 968
11
来自主题: JobHunting版 - Longest common string问题
他说的方法挺好的
longest palindrome, 就可以用string 和 reverseed string, 然后DP找LCS, 现场
coding也比较方便.
更好的就是你提到的suffix tree
I**A
发帖数: 2345
12
thanks,这个好理解。。
复杂度o(n^2*m) where n is length(s1) and m is length(s2)
如果我已经有了一个算法,就是得到一个string的longest repeated substring,
有没有办法调用这个function来求 longest common substring of two strings?
I**A
发帖数: 2345
13
来自主题: JobHunting版 - 问个string combination的问题
啊,对不起,也许我理解有误。
我把自己给饶糊涂了。。
对于bcb这个输入, 输出的cb应该是理解为跟bc不同的还是相同的??
同学们,你们谁给讲解一下?
我原来想说的意思是,"abc"这个输入,不应该出现cb做为输出。。
HashSet挺好的,问题就是我在实现的时候必须把它设置为instance variable,而不能
用一个local variable..我不是很喜欢这个global变量 idea..
(延伸问题:In "bcb" input case, 如果bc and cb算是重复的,how to check it with HashSet?)
帮我看看,是不是可以改进?
HashSet set = new HashSet();
public void doCombine(char[] instr, StringBuilder outstr, int start,
int end){
for(int i=start; i outstr.append(instr[i]);
y*********e
发帖数: 518
14
来自主题: JobHunting版 - 一道面试题(integer to binary string)
上完整代码:
public String intToBits(int value) {
long i = value;
if (i < 0)
i = Integer.MAX_VALUE - (-i) + 1;
// i is unsigned then
char[] buff = new char[32];
for (int j = 31; j >= 0; j--) {
boolean bit = (i & 1 == 1);
buff[j] = '0' + (int)bit;
i = i >> 1;
}
return new String(buff);
}
d**e
发帖数: 6098
15
google string tokenizer c++ 应该有收获

a
j*****g
发帖数: 223
16
Still looking at @ihasleetcode suggested Dr.Dobbs algorithm which looks like
a suffix tree matching.
As for @done, does your algorithm pass on this test case?
string : abc
pattern: b*
It's a not match. But in your code, the inner loop will break out when
comparing 'a' vs 'b'. after breaking out, the outer loop will advance s
pointer, so next time, p1 will be pointing at 'b', and s1 will be pointing
at 'b'. After that, seems your algorithm will match them and return 1.
Can you double check?
BTW, ... 阅读全帖
i**********e
发帖数: 1145
17
No need suffix tree or any advanced data structure. No need dynamic
programming. All you need is two pointers,
iterating through the pattern and string at the same time. Need to take
extra care for special cases.
I have wrote the code below:
bool match(const char *str, const char *pattern) {
const char *p1 = pattern, *p2 = str;
if (*p1 && *p1 != '*' && *p1 != *p2)
return false;
while (*p1) {
while (*p1 == '*')
p1++;
if (!*p1) return true;
while (*p2 && *p1 != *p2)
... 阅读全帖
i**********e
发帖数: 1145
18
Great attempt.
I think you have a pretty good approach here using DP.
However, I think you still missed few test cases:
Try pattern "*o*" and string "hello", it should return true.
and pattern "a" and string "aa", it should return false.
i**********e
发帖数: 1145
19
The purpose of the code is to match the end of the string with the pattern:
For example,
pattern="h*llo"
string="hellohellc"
The code will ensure that if the last character is not a '*', then it will
match the last section letter by letter.
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

s1
e**********6
发帖数: 78
20
来自主题: JobHunting版 - 一道有关String的面试题
有一个String里面的词被scrambled了,而且空格被删除。给你一个单词列表,让还原
String以前的形态。
input: hlleowlord
list of words: hello, world, hi, dog, cat
output: hello world
刚开始想sort,然后用hashtable。但后来发现sort input的话单词就混在一起了,根
本找不到words。比如变成:dehllloorw。
有什么高效率的好方法吗?
m*****t
发帖数: 334
21
void revert(char *str)
How to revert a string in-place and only scan the string once? (Remember, if
you use strlen() then it counts as one scan)
s******g
发帖数: 46
22
来自主题: JobHunting版 - 请教:string pattern match 题
刚开始找工作,面试了几家,好几次被问到了这道题,想来应该是经典题了,可是搜了
一下,没发现很直接的答案,所以想请教大家。
题目是:
有一个不定长的char string (S1),都是0,1组成;另外一个string (S2), 也是0,1
组成,可以认为是pattern,问S1中是否含有S2
e.g S1 = 11100011 10101011 11111111 10000100 ( 4 bytes, '11100011' is 1 byte)
S2 = 00111010
the answer is ture, 1110"00111010"1011
希望讲清楚了,先谢谢了
h*****g
发帖数: 944
23
来自主题: JobHunting版 - BB试题:如何创建2D array of String?
今天被问到如和在c++里创建a two -dimensional array of string?
我这解说 String hi [20][20];
好像错了,似乎c++不支持这么做,请问应该怎么declare?
char * hi [20][20]好像也不对吧
n*******r
发帖数: 22
24
来自主题: JobHunting版 - BB试题:如何创建2D array of String?
1. vector< vector > vvs;
2. string *ppstr[row];
w**t
发帖数: 592
25
题目是写一个memory and/or speed优化的程序,只有一个输入值,不能用hash map,
如何写?string有重复字符
比如 void perm(const char* str)
我给出的是用递归+hash map,所有中间变量用static variable,permuted string放
在一个static hash map 里。显然
他不认为是最优解。
s*****y
发帖数: 897
26
根据题目和next_permutation 的实现,写了个相应的,assume input string is
sorted
inline void swap(char *i, char *j) {
char tmp = *i;
*i = *j;
*j = tmp;
}
inline void reverse(char *start, char *end){
while (start < end) {
swap(start, end);
start ++;
end--;
}
}
bool perm_loop(char *str, char *start, char *end) {
char *i = end-1;
//find first two pairs from the end that *i < *(i+1)
while((i >= start) &&(*i >= *(i+1))) i--;
//could not find such pair
if... 阅读全帖
w**t
发帖数: 592
27
题目是写一个memory and/or speed优化的程序,只有一个输入值,不能用hash map,
如何写?string有重复字符
比如 void perm(const char* str)
我给出的是用递归+hash map,所有中间变量用static variable,permuted string放
在一个static hash map 里。显然
他不认为是最优解。
s*****y
发帖数: 897
28
根据题目和next_permutation 的实现,写了个相应的,assume input string is
sorted
inline void swap(char *i, char *j) {
char tmp = *i;
*i = *j;
*j = tmp;
}
inline void reverse(char *start, char *end){
while (start < end) {
swap(start, end);
start ++;
end--;
}
}
bool perm_loop(char *str, char *start, char *end) {
char *i = end-1;
//find first two pairs from the end that *i < *(i+1)
while((i >= start) &&(*i >= *(i+1))) i--;
//could not find such pair
if... 阅读全帖
F**r
发帖数: 84
29
来自主题: JobHunting版 - 问2个string matching的题
for 32.1-4, use the same idea as KMP plus wild string matching, complexity
is O(n*k), n is the length of the searching text, k is the number of the
wild characters in the pattern string.
for 32.2-3, use the idea in image processing. sliding window
u****g
发帖数: 402
30
来自主题: JobHunting版 - c/c++ qsort/sort 来 sort array of string
online测试题,哪个function 可以来 sort array of string,
qsort or sort?
网上搜出来的都是在讲怎么用qsort来排序array of string, 但sort应该更好用并且更
简单吧。
h******3
发帖数: 351
31
assume s = word.substring(0, i)
examine whether the string "("+s+")" matches pattern or not. ^ indicates
beginning of a string, $-ending.
D*******e
发帖数: 151
32
split the strings into buckets, e.g., from a to z 26 ones
count them separately
then merge the results
f*******t
发帖数: 7549
33
以前有帖讨论过。可以用bloom filter把只出现一次的string去掉,通过的用堆存,算
是一种实际应用中比较有效的办法吧。
不知道最佳答案是什么
B*******1
发帖数: 2454
34
来自主题: JobHunting版 - 任意输入STRING,转换为INTEGER,
atoi
function

int atoi ( const char * str );
Convert string to integer
Parses the C string str interpreting its content as an integral number,
which is returned as an int value.
The function first discards as many whitespace characters as necessary until
the first non-whitespace character is found. Then, starting from this
character, takes an optional initial plus or minus sign followed by as many
numerical digits as possible, and interprets them as a numerical value.
n******n
发帖数: 49
35
我对题意的理解是:
比如
the list of words with the same size: abc, def, ghi
the big string: xxxdefghiabcxxxxxx
应该返回3,因为defghiabc是一个(abc, def, ghi)的permutation, 它在big string中
起始index是3.
n******n
发帖数: 49
36
我对题意的理解是:
比如
the list of words with the same size: abc, def, ghi
the big string: xxxdefghiabcxxxxxx
应该返回3,因为defghiabc是一个(abc, def, ghi)的permutation, 它在big string中
起始index是3.
H***e
发帖数: 476
37
来自主题: JobHunting版 - 看一道string permutation的题目吧
string = '"abc",
打印所有长度为6的字符可以重复的string permutation(但是输出不能重复)
也就是打印
aaaaaa
aaaaab
aaaaac
aaabac
....
我觉得很费解。
w*******s
发帖数: 96
38
Two implementation. one use sort and one use hash.
//pre: str is sorted.
void PermutationWithDuplicate(char *str, int position)
{
if (position == strlen(str)) {
printf("%s", str);
return;
}

char lastChar = '\0';
for (int i = position; i {
//skip those character which is duplicated. Since the string is
sorted, it's easy.
if (lastChar == str[i] ) continue;

lastChar = str[i];
swap(str[po... 阅读全帖
z****h
发帖数: 164
39
private void printstringwithprefix(String[] ss, String prefix) {
if(ss == null) return;
if(prefix == null || prefix.isEmpty()) return;
int low = 0;
int high = ss.length -1;
for(int i = 0; i< prefix.length() && low <= high; i++)
{
int mid = (low+high)/2;

if(i >= ss[mid].length())
{
return;
}

if(ss[mid].charAt(i) < prefix.charAt(i))
... 阅读全帖
p*****2
发帖数: 21240
40

String[] ss = new String[]
{ "aaa", "abc", "abcd", "abcde", "bbb" };
out.println(Find(ss, "abcde", true));
out.println(Find(ss, "abcde", false));
o我的程序返回3
w****x
发帖数: 2483
41
来自主题: JobHunting版 - 做了一下scramble string
/*
scramble string,judge if one string can be scrambled to another one
tiger
/ \
ti ger
/ \ / \
t i g er
/ \
e r
rotation is allowded
itreg
/ \
it reg
/ \ / \
t i g re
/ \
e r
then tiger can be changed to itreg
*/
bool _inner_can_scramble(const char* szStr1, const char* szStr2, int n);
bool CanScramble(const char* szStr1, const char* szStr2)
{
assert(szStr1 && szStr2);
int nLen1 = strlen(szStr1);
int nLen2 = strlen(szStr2);
if (nLen1 !... 阅读全帖
w****x
发帖数: 2483
42
来自主题: JobHunting版 - google scramble string O(n) 解法
贴一个递归和DP的:
/*
scramble string,judge if one string can be scrambled to another one
tiger
/ \
ti ger
/ \ / \
t i g er
/ \
e r
rotation is allowded
itreg
/ \
it reg
/ \ / \
t i g re
/ \
e r
then tiger can be changed to itreg
*/
bool _inner_can_scramble(const char* szStr1, const char* szStr2, int n);
bool CanScramble(const char* szStr1, const char* szStr2)
{
assert(szStr1 && szStr2);
int nLen1 = strlen(szStr1);
int nLen2 = strlen(szStr2);
... 阅读全帖
t*****j
发帖数: 1105
43
来自主题: JobHunting版 - google scramble string O(n) 解法
我也回报一下。递归的,复杂度是二叉树层数*字符串个数。空间复杂度也是O(n).
今晚刚写的,test过了。
bool isSubAnargm(string parent, string child)
{
if(parent.empty() && child.empty()) return true;
for(unsigned int i = 0; i< child.size(); i++)
{
if (parent.find(child[i]) < 0) return false;
}
if (parent.find(child[0]) > parent.find(child[child.size()-1]))
{
reverse(parent.begin(), parent.end());
};
if (parent.compare(child) == 0) return true;
int currentMaxPosition = -1;
int validMaxLeng... 阅读全帖
m********c
发帖数: 105
44
来自主题: JobHunting版 - google scramble string O(n) 解法
贴一个我的recursive代码,time complexity是O(n^2),large Judge用了144ms,不
是最优解,但是容易理解
bool isScramble(string s1, string s2) {
// Start typing your C/C++ solution below
// DO NOT write int main() function

if (s1 == s2)
return true;

int size = s1.size();

int value1=0, value2=0;
for (int i=0; i value1 += (s1[i]-'a');
value2 += (s2[i]-'a');
}
if (value1 != value2)
r... 阅读全帖
f*********i
发帖数: 197
45
来自主题: JobHunting版 - 关于leetcode的Scramble String问题
啊,这个blog是我写的,居然被翻出来了。
很惭愧,这个方法后来被人发现只能作用于unique character string,如果一个
string里面有duplication,那么就要做data pre-processing,找出所有可能的排列,
然后一一比较。 那样的话时间复杂度就高了。
我曾经考虑过用一个list来表达不同情况下的merge,但是发现这个方法太复杂,没有
头绪。
请高人赐教
x*******6
发帖数: 262
46
来自主题: JobHunting版 - 关于leetcode的Scramble String问题
请问sramble string和anagram有什么区别?不能将string里面的char排序然后看是否
一样么?
w****x
发帖数: 2483
47
来自主题: JobHunting版 - LeetCode Scramble String 疑问
/*
scramble string,judge if one string can be scrambled to another one
tiger
/ \
ti ger
/ \ / \
t i g er
/ \
e r
rotation is allowded
itreg
/ \
it reg
/ \ / \
t i g re
/ \
e r
then tiger can be changed to itreg
*/
bool _inner_can_scramble(const char* szStr1, const char* szStr2, int n);
bool CanScramble(const char* szStr1, const char* szStr2)
{
assert(szStr1 && szStr2);
int nLen1 = strlen(szStr1);
int nLen2 = strlen(szStr2);
if (nLen1 !... 阅读全帖
b*******d
发帖数: 750
48
来自主题: JobHunting版 - Find consecutive repeated string

duplicate
可以用修改后的suffix tree么?build suffix是linear time,虽然那个算法非常复杂
,很难一下写出来。但是其上每个node的path(从根开始的path)都是一个substring
。把每个node设计成
node {
char c;
List startPos;// 记录下这个node的从根到该node的path的起始点在原
string的位置。是个list因为可能有很多个这种string。
int pathLen; // 记录下这个node的从根到该弄得的path的长度,即该substring的
length。
}
build suffix tree的时候,如果add node时候,发现该node已经存在,说明该
substring已经存在,如果存在一个startPos + pathLen == curStartPos,说明存在一
个连续repeated的substring。
应该是linear time
p*****2
发帖数: 21240
49
我觉得这题面试最好还是用DP来解。
public boolean isMatch(String s, String p)
{
int n=s.length();
int m=p.length();

boolean[][] dp=new boolean[2][n+1];
dp[m%2][n]=true;

for(int i=m-1;i>=0;i--)
{
Arrays.fill(dp[i%2], false);
if(p.charAt(i)=='*')
for(int j=n;j>=0;j--)
{
if(dp[(i+1)%2][j])
for(int k=0;k<=j;k++)
dp[i%2][k... 阅读全帖
p*****2
发帖数: 21240
50

你再仔细看看。不过我可以换一种写法就更清楚了。
public boolean isMatch(String s, String p)
{
int n=s.length();
int m=p.length();

boolean[][] dp=new boolean[2][n+1];
dp[m%2][n]=true;

for(int i=m-1;i>=0;i--)
{
Arrays.fill(dp[i%2], false);
dp[i%2][n]=p.charAt(i)=='*' && dp[(i+1)%2][n];
for(int j=n-1;j>=0;j--)
if(p.charAt(i)=='*')
dp[i%2][j]=dp[(i+1)%2][j] || dp[i%2][j+1];
... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 (共10页)