由买买提看人间百态

topics

全部话题 - 话题: pstart
(共0页)
s*******f
发帖数: 1114
1
来自主题: JobHunting版 - 攒个人品,发个google电话面试题
//回报本版,码遍本版
//Given a string of sorted integers, e.g. "1 52 69 456789 994546566";
//and a a number e.g. 69.
//You need to tell if it is in the input, e.g. 69=>true.
//strlen is O(n), don't use C style string for O(log n), suppose
//the string is friendly without lots of blank.
void GetWordPos(const char *mid, const char *left, const char *right, const
char **pstart, const char **pend){
while (isspace(*mid))
++mid;
*pstart = mid;
while (*pstart >= left && !isspace(**pstart))
... 阅读全帖




发帖数: 1
2
来自主题: JobHunting版 - yahoo 这个公司怎么样?
好长时间没上Yahoo,刚发现界面变了!比原来强多了。在变,没准还有希望。只是感
觉页面有点慢,随便找个网页,发现每个td来一堆class,有这必要吗?还能不慢?
1 https://s.yimg.com/wv/images/f936161c385c9ad292d21c1c248edb59_
48.png" alt="AuntKatie" />
A... 阅读全帖
y****k
发帖数: 71
3
来自主题: Military版 - c++ thread 求助 (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: ystdpk (ystdpk), 信区: Programming
标 题: c++ thread 求助
发信站: BBS 未名空间站 (Fri Jan 31 21:12:20 2014, 美东)
有一个50 million 行的文本。每行四列数字。
要求每行求一个特殊函数的值,把此值输出为第五列。次函数的求值所花的时间可能很
快,如果四个数比较小, 也可能要花到10几到100倍的时间如果数比较大。
想用36个boost thread。
有没有人能提供一个boost thread 的代码。谢谢了。
我写了一个下面的,但是cpu浪费比较严重,有的thread 结束早,有的结束慢。而且不
知道2000行一个thread是不是好的选择。
int batchSize = 2000;
int num_of_lines = 50100100;
bool end_of_file = false;
int pstart = 0;
boost::thread_group io;
while( ! end_of_file )
{
b... 阅读全帖
y****k
发帖数: 71
4
来自主题: JobHunting版 - c++ thread 求助 (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: ystdpk (ystdpk), 信区: Programming
标 题: c++ thread 求助
发信站: BBS 未名空间站 (Fri Jan 31 21:12:20 2014, 美东)
有一个50 million 行的文本。每行四列数字。
要求每行求一个特殊函数的值,把此值输出为第五列。次函数的求值所花的时间可能很
快,如果四个数比较小, 也可能要花到10几到100倍的时间如果数比较大。
想用36个boost thread。
有没有人能提供一个boost thread 的代码。谢谢了。
我写了一个下面的,但是cpu浪费比较严重,有的thread 结束早,有的结束慢。而且不
知道2000行一个thread是不是好的选择。
int batchSize = 2000;
int num_of_lines = 50100100;
bool end_of_file = false;
int pstart = 0;
boost::thread_group io;
while( ! end_of_file )
{
b... 阅读全帖
y****k
发帖数: 71
5
来自主题: Programming版 - c++ thread 求助
有一个50 million 行的文本。每行四列数字。
要求每行求一个特殊函数的值,把此值输出为第五列。次函数的求值所花的时间可能很
快,如果四个数比较小, 也可能要花到10几到100倍的时间如果数比较大。
想用36个boost thread。
有没有人能提供一个boost thread 的代码。谢谢了。
我写了一个下面的,但是cpu浪费比较严重,有的thread 结束早,有的结束慢。而且不
知道2000行一个thread是不是好的选择。
int batchSize = 2000;
int num_of_lines = 50100100;
bool end_of_file = false;
int pstart = 0;
boost::thread_group io;
while( ! end_of_file )
{
boost::thread_group g;
vector > out;
out.resize(num_of_threads);

for( int i = 0; i < num_of_threads; ... 阅读全帖
m*****s
发帖数: 19
6
来自主题: JobHunting版 - 问个ms的面试题
两个指针一头一尾pstart, pend.并且一直记录从pstart到pend的和sum
向后一位一位移动pend,更新sum
如果sum小于0了,向后移动pstart直到sum〉=0,(总可以〉=0的,因为重合时就〉=0)
如果大于等于0了就停止移动pstart,再移动pend。一直这样循环,直到pend-pstart =
sizeof(pointer) * (n-1)
这时候返回pstart

the
amount
you
between
n********y
发帖数: 66
7
欢迎拍砖,就用了一个 256 字节的table来检查一个数字是否出现过
#include
#include
#include
#include
char* nextpointer(char* str, int strlen)
{
char *p = str;
char *pend = str + strlen;
char count[256];
memset(count, 0, sizeof(count));
while (p < pend)
{
++count[*p];
if (count[*p] > 1)
{
return p;
}
++p;
}
return p;
}
void longestsingle(char* str, int strlen)
{
char *pstart = str;
char *pend... 阅读全帖
c***2
发帖数: 838
8
Here's the full file. You may compile and run: any case I missed?
==================================================================
/* wild.c
*/
#include
#include
#include
#define STR_SIZE 256
//===========================================================
int matchndots(const char *text, const char *dstr, int len)
{
while(len&&*text&&*dstr&&(*text==*dstr || *dstr=='.')){
text++;
dstr++;
len--;
}

if(!len)
return 1;
... 阅读全帖
P********l
发帖数: 452
9
来自主题: JobHunting版 - 问一个算法题
http://www.sureinterview.com/shwqst/545001
code:
public void findRange(double[] data, double rangeStart, double rangeEnd,
Mutable pStart, Mutable pEnd) {
pStart.setValue(-1);
pEnd.setValue(-1);
if (data == null || data.length == 0)
return;
int posStart = 0, posEnd = data.length - 1;
// find where the data roughly is.
int inRange = 0;
while (posStart <= posEnd) {
inRange = (posStart + posEnd) / 2;
if (data[in... 阅读全帖
P****2
发帖数: 197
10
来自主题: JobHunting版 - Google 需要bug free 么?
最短SNIPPETS变形吧,一样2指针2字典,O(n)扫过去
public bool IsAnagramSubString(string str, string anagram)
{
var pStart = 0;
var pEnd = 0;
var targetDict = anagram.GroupBy(p => p)
.ToDictionary(
g => g.Key,
g => g.Count()
);
var targetTotalNum = targetDict.Values.Sum();
var foundDict = targetDict.ToDictionary(p => p.Key, p => 0);
var foundTotalNum = 0;
wh... 阅读全帖
B*****g
发帖数: 34098
11
No sql server ENV, hehe
SUPPOSE there is no 2 records in tableA has value different less than 401.
SELECT b.*, 'group' ||RANK() OVER (ORDER BY a1.name, a2.name)
FROM tableB b, tableA a1, tableA a2
WHERE ABS(b.pstart-a1.point) <= 200
AND ABS(b.pend-a2.point) <= 200
(共0页)