c***2 发帖数: 838 | 1 sprintf(buf, "%f", ...)
then add , in buf for each 3 chars |
|
c***2 发帖数: 838 | 2 agree.
1) in place
char *reverse(char *str)
2) into another buf version 1
char *reverse(const char *src, char *dst)
3) into another buf version 2
char *reverse(const char *src) |
|
l*********8 发帖数: 4642 | 3 #include
#include
int main(int argc, char * argv[])
{
char * s[4] = {"000", "Fizz", "Buzz", "FizzBuzz"};
char buf[4];
for (int x=1; x<=100; x++) {
s[0] = itoa(x, buf, 10);
printf("%s\n", s[ !(x%3) + 2*!(x%5) ] );
}
return 0;
} |
|
S**I 发帖数: 15689 | 4 ☆─────────────────────────────────────☆
coconut001 (coconut001) 于 (Sat Apr 16 20:51:09 2011, 美东) 提到:
我是这周三面试的,周四回来歇了两天,压跟就没有心情来版上询问。我总共面了6个
人,5个
leader(真的各个title都是leader or senior leader,我就纳闷,M家木有engineer
吗?)和一
个PM。 问题比较简单,
实现strcmp,
实现malloc and free,讨论memory leak怎么解决,以及memory fragment问题
pointer问题(这个问的很杂,比如什么指针存的是一个已经out of scope的address之
后会发生
什么之类的,具体记不清楚了)
multi-processor相关问题,比如multi-processor的机器实现lock要怎么做,我好像说
了memory
bus之类的,中断这时候不起作用了。
Open question(这个问题我用数学模型解释,以至于面我的人以为我是Math的。。。
。。。... 阅读全帖 |
|
n*******s 发帖数: 482 | 5 readline()内部要有一个buffer来缓存以减少IO operation.
assume 该缓存是
static char buff[MAX]
static int size ; // current bond of the data in buffer
static int index ; // index of current reader pointer in the buffer
static char resultBuff[MAX]
另外 几个case需要考虑到
(1) there is a '\n' between index and size : just copy them out and return.
and update index.
(2) no '\n' between index and size, now things get complicated
no matter what, need to save the current data between index and max to
resultBuffer, set index to... 阅读全帖 |
|
k*****y 发帖数: 744 | 6 请问像 s = "abadabadabadeabecd", p = "*ab?c*d"这样的不用递归怎么办?
我也贴一个,大家帮忙看看,谢谢~
===========================
bool isMatch(const char* s, const char* p) {
if(*s == 0) return !hasNonStar(p);
if(*p == 0) return false;
if(*p != '*'){ //case: *p != '*'
while(*s && *p && *p!='*') {
if(*p!='?' && *p!=*s)
return false;
++p; ++s;
}
return isMatch(s, p);
}
else{ // case: *p == '*'
if(!skipStars(s, p)) return false;
... 阅读全帖 |
|
G******i 发帖数: 5226 | 7 ☆─────────────────────────────────────☆
guangyi ( 光一) 于 (Sat Oct 29 00:10:37 2011, 美东) 提到:
**********************************
M:
phone interview (1 round):
why MS?
biggest challenge
why like coding and algorithm?
what is good code?
your longest code
biggest accomplishment
if you don't want some functions to be modified in java, what to do?
does java allow multiple inheritance?
what does synchronized keyword mean in java?
CEO wants a book, you find it in the system of a nearby bookshop. You ... 阅读全帖 |
|
d**********x 发帖数: 4083 | 8 不要用stringstream,很少有人用的东西,效率也有问题。
在vs2008里当年还有个臭名昭著的memory leak问题。
int2str直接用snprintf即可。因为int输出的位数很确定,所以不会有buf长度问题。
snprintf(buf, "%d", x); |
|
h********0 发帖数: 74 | 9 how about this, a java version
static int BLOCKSIZE = 4096;
/*
* 内部有个静态文件指针,只能向文件末尾移动,每次只能读取4K的block到buf里,
* 返回读取的字节数(除非到文件尾,否则总是4K)
*/
private int read4096(byte[] buf) {
//this is a fake
return Math.random() > 0.9 ? 1024 : 4096;
}
/**
* read bytes and fill in the contain of 'output'
*
* Testcases:
* 1 just want to read 3k, it < 4k, and the file is enough
* 2 just want to read 5k, 4k < it < 8k, and the file is enough
* 3 want too much, read all rem... 阅读全帖 |
|
d*k 发帖数: 207 | 10 看了大家的討論,優化下內存拷貝次數
int Read(int size, char* buffer) {
int n = size / 4;
int ret = 0;
for (int i = 0; i < n; ++i) {
int t = Read4(buffer + ret);
ret += t;
if (t < 4) {
return ret;
}
}
int left = size % 4;
char buf[4];
int sz = min(left, Read4(buf));
memcpy(buffer + ret, sz);
ret += sz;
return ret;
} |
|
s********u 发帖数: 1109 | 11 这是readline那个题我参照网上的代码写的。比这个要复杂一些,因为一个line的字符
是不确定的。
#define MAX_LEN 4096
int read(char* buf, int len);
char *readLine(){
static bool EOF = false;
char *str = NULL;
int i, size = 0;
static int currentPos = MAX_LEN;
static char* buffer = new char[MAX_LEN];
while(!EOF || currentPos != MAX_LEN ){
// buffer is not empty, handle buffer first
if(currentPos != MAX_LEN){
for(i = currentPos; i < MAX_LEN; i++)
... 阅读全帖 |
|
s********u 发帖数: 1109 | 12 嗯 作为类的变量也行 不过我所说的static的是4的那个buf,而不是输出的buffer。输
出那个buffer是个参数,应该是可以用户来给定的,或者相当于一个返回值。这个题应
该是这个意思。所以你不能把余下来的东西存在buffer里,而要存在buf里。。。。好绕 |
|
b**********5 发帖数: 7881 | 13 那个buf, 就是个char[4] buf吧, 一共就四个char的memory, 查一查里面有什么
valid char, 不就行了? |
|
s********u 发帖数: 1109 | 14 老题了吧,不过老要写错,尤其是那个read4写read的更恶心。
#define MAX_LEN 4096
int read(char* buf, int len);
char *readLine(){
static bool EOF = false;
char *str = NULL;
int i, size = 0;
static int currentPos = MAX_LEN;
static char* buffer = new char[MAX_LEN];
while(!EOF || currentPos != MAX_LEN ){
// buffer is not empty, handle buffer first
if(currentPos != MAX_LEN){
for(i = currentPos; i < MAX_LEN; i++)
if( buffer[i] ==... 阅读全帖 |
|
f********4 发帖数: 988 | 15 哦,我去看看rolling hash是神马东西。。
push back和 substr时间复杂度应该都是liner的吧,因为只有10个character,但是空
间复杂度就不好说了,buf = buf.substr(1)我也搞不清是不是call 了copy
constructor |
|
h**o 发帖数: 548 | 16 usually there are two FAQ about this topic, sometimes readN(char* dst, int
size) is asked during interview, given read4096(char* buf); sometimes
readLine(char* dst) is asked, given read4096(char* buf). I am writing both. |
|
s**x 发帖数: 7506 | 17 I see.
"bytes+=memcpy(dst+bytes, buf, min); "
buf should be ptr here? |
|
h**o 发帖数: 548 | 18 usually there are two FAQ about this topic, sometimes readN(char* dst, int
size) is asked during interview, given read4096(char* buf); sometimes
readLine(char* dst) is asked, given read4096(char* buf). I am writing both. |
|
s**x 发帖数: 7506 | 19 I see.
"bytes+=memcpy(dst+bytes, buf, min); "
buf should be ptr here? |
|
f******4 发帖数: 51 | 20 FG以前都面过的题目,貌似出现概率不低。搜索+论坛考古之后实在没有研究出满意的
答案,
原题如下:
Given API:
int Read4096(char* buf);
It reads data from a file and records the position so that the next time
when it is called it reads the next 4k chars (or the rest of the file,
whichever is smaller) from the file.
The return is the number of chars read.
Todo: Use above API to Implement API
"int Read(char* buf, int n)" which reads any number of chars from the file.
有没有大牛甩个python解法 |
|
f******4 发帖数: 51 | 21
buf是Input param, buf += total显然有问题a |
|
f******4 发帖数: 51 | 22 FG以前都面过的题目,貌似出现概率不低。搜索+论坛考古之后实在没有研究出满意的
答案,
原题如下:
Given API:
int Read4096(char* buf);
It reads data from a file and records the position so that the next time
when it is called it reads the next 4k chars (or the rest of the file,
whichever is smaller) from the file.
The return is the number of chars read.
Todo: Use above API to Implement API
"int Read(char* buf, int n)" which reads any number of chars from the file.
有没有大牛甩个python解法 |
|
f******4 发帖数: 51 | 23
buf是Input param, buf += total显然有问题a |
|
w*****r 发帖数: 42 | 24 Read N Characters Given Read4 II - Call multiple times
The API: int read4(char *buf) reads 4 characters at a time from a file.
The return value is the actual number of characters read. For example, it
returns 3 if there is only 3 characters left in the file.
By using the read4 API, implement the function int read(char *buf, int n)
that reads n characters from the file.
Note:
The read function may be called multiple times.
有人做了吗?第一次读多了以后怎么把文件指针退回去? 还是有别的办法?我用原来
那个读一次的代码试了一下,过不了下面这个testcase.
Input... 阅读全帖 |
|
r*******e 发帖数: 971 | 25 我怎么感觉你这个解法有问题。
int sz = read4(buf);
这行跑完了,如果buf不变,那么以后每次写字符都是在前4个字符上重复操作。 |
|
y*****e 发帖数: 712 | 26 buf+=bytes;
buf在往后挪啊。。。。 |
|
f********c 发帖数: 147 | 27 应该buf是destination. buffer是缓冲,暂时存储从read4读取的数据,然后System.
arraycopy那一行是把buffer里面的数据copy到buf里面。 |
|
h**d 发帖数: 5161 | 28 双方有些误会吧。
你问的问题,他的回答你没有理解,而对方认为很清楚了。
fillBufferFromFile在写入的过程中, 有没有
写入什么metadata? 他说, fillBufferFromFile()只是个API, 不用你实现; 我又问,
有没有返回什么辅助数据结构让你能标志哪些buffer被用了, 哪些buffer是free的
其实这么回答比较好:fillBufferFromFile 就是把Disk的内容Copy到buf,不做别的操
作。onShutdown 就是把buf copy到Disk,也不做别的操作。
也许这么一说你会发现这个题挺简单,当然还是很考察基本功的。题目本身出的不错。
persistent |
|
k******4 发帖数: 7 | 29 为了防止违反NDA,就不列出公司名了,就是一些常见公司。
1. Write a iterator to iterate a nested array.
For example, for given array: [1, 2, [3, [4, 5], [6, 7], 8], 9, 10]
call iterator.next() 10 times should return 1,2,3,4,5,6,7,8,9,10.
用了stack存(array, index)的tuple。
2. LeetCode 原题,120 - Triange。有一点变种,给的是一维数组。
3. Implement HashTable 主要看dynamic expanding
4. Implement MaxHeap.
5. Topology sort,就是版上常见的给一些排过序的未知语言的词,求该语言的字母序
。要求实现核心算法。可以给出一些helper function定义不需实现。
6. LeetCode 付费题 157 & 158 - Read N Characters Given Rea... 阅读全帖 |
|
b*****g 发帖数: 46 | 30 举几个例子你就明白了。
Read4:
Buf=“abcdefg”
每个test case只会调用你写的函数一次,比如
read(3), 返回“abc”,这个case 就结束了
read(3), 还是返回“abc”
Read4 II
每个test case可能会调用你写的函数多次
同样的buf
read(3), 返回”abc”,再read(3), 这次要返回“def” |
|
|
u****q 发帖数: 24345 | 32 buffing wheel + buffing compound |
|
m*****0 发帖数: 390 | 33 我妈身体不好,用里程订了AA的商务舱从BUF-ORD-PVG,但是转机时间只有50多分钟,
最近观察了一阵,11月份BUF-ORD的准点率(arrival within 14min as the schedule
)只有62%,感觉最近的准点率更差。 如果误了机,基本只能在芝加哥住一夜第二天再
走。
但是我妈不会说英文,假如误机的话会比较麻烦,估计比较难找到旅馆。不知道行李需
不需要自己拿?
或者就是把AA退掉(不知道像这种短时间的转机情况,可否把$150的redeposit fee
waive掉?)然后我开车去多伦多直飞东航的,这种情况估计只能买个经济舱。
不知道我这种情况怎么选择好?谢谢 |
|
h****s 发帖数: 16779 | 34 东航saver商务票很多。 直飞商务吧。
[在 majia10 (马甲) 的大作中提到:]
:我妈身体不好,用里程订了AA的商务舱从BUF-ORD-PVG,但是转机时间只有50多分钟,
:最近观察了一阵,11月份BUF-ORD的准点率(arrival within 14min as the schedule
:)只有62%,感觉最近的准点率更差。 如果误了机,基本只能在芝加哥住一夜第二天
再走。
:但是我妈不会说英文,假如误机的话会比较麻烦,估计比较难找到旅馆。不知道行李
需不需要自己拿?
:或者就是把AA退掉(不知道像这种短时间的转机情况,可否把$150的redeposit fee
:waive掉?)然后我开车去多伦多直飞东航的,这种情况估计只能买个经济舱。
:不知道我这种情况怎么选择好?谢谢 |
|
T******r 发帖数: 2937 | 35 QB: K. Collins(Oak) J.Losman(Buf)
WR: N.Burleson(Min)
Ro.Smith(Den)
D.Givens(NE)
D.Pattern(Was)
R.Curry(Oak)
R.Parrish(Buf)
RB: T.理发师
D.Foster(Car)
W.Dunn(Atl)
TE: L.Smith(Phi)
K.mangum(car)
K: R.Longwell(GB)
DEF: Jacksonville |
|
b***n 发帖数: 13455 | 36 ☆─────────────────────────────────────☆
bison (九尖山下仙, 石象湖边客) 于 (Thu Dec 21 21:32:11 2006) 提到:
TB vs. CLE
TEN vs. BUF
BAL vs. PIT
SD vs. SEA
Powerball: PHI vs. DAL
☆─────────────────────────────────────☆
fan (阿道克船长) 于 (Thu Dec 21 23:30:03 2006) 提到:
2 bet
TB
TEN
BAL
SD
23:28 Dal
☆─────────────────────────────────────☆
bison (九尖山下仙, 石象湖边客) 于 (Fri Dec 22 22:03:39 2006) 提到:
1
CLE
BUF
BAL
SD
Powerball: DAL 27:24
☆─────────────────────────────────────☆
yingle (a comeback story) 于 |
|
b******u 发帖数: 469 | 37 168.00
44.00 Tom Brady NWE QB
TEN 0 FINAL
NWE 59
29-34, 380 yds passing (6 TDs)
27.00 DeAngelo Williams CAR RB
CAR 28 FINAL
TAM 21
30 carries, 152 yds rushing (2 TDs)
2 catches, 20 yds receiving
32.00 Ray Rice BAL RB
BAL 31 FINAL
MIN 33
10 carries, 77 yds rushing (2 TDs)
10 catches, 117 yds receiving
11.00 Lee Evans BUF WR
BUF 16 FINAL
NYJ 13
4 catches, 68 yds receiving (1 TD |
|
G**Y 发帖数: 33224 | 38 用你的模板,查了一下95码以上的,发叔,Brady,大本都有。呵呵
Count
1
Sonny Jurgensen*
Gerry Allen
1968
1968
WAS
1
2
Randall Cunningham
Fred Barnett
1990
1990
PHI
1
3
Gus Frerotte
Bernard Berrian
2008
2008
MIN
1
4
Trent Green
Marc Boerigter
2002
2002
KAN
1
5
Bobby Layne*
Cloyce Box
1953
1953
DET
1
6
Jim Plunkett
Cliff Branch
1983
1983
RAI
1
7
Brett Favre
Robert Brooks
1995
1995
GNB
1
8
George Blanda*
Dick Compton
1965
1965
HOU
1
9
Eli Manning
Victor Cruz
2011
2011
NYG
1
10
Jeff Garcia
Andre' Davis
2004
2004
CLE
1
11
Jacky ... 阅读全帖 |
|
d*********o 发帖数: 6388 | 39 https://www.profootballfocus.com/blog/2014/02/12/signature-stats-accuracy-
percentage-breakdown/
The Top 10
Name Team Accuracy %
Aaron Rodgers GB 79.3%
Philip Rivers SD 78.7%
Matt Ryan ATL 78.4%
Josh McCown CHI 77.8%
Peyton Manning DEN 77.0%
Drew Brees NO 77.0%
Sam Bradford STL 74.7%
Ben Roethlisberger PIT 74.7%
Matt Flynn GB 74.7%
Nick Foles PHI 74.2%
The Bottom 10
Name Team Accuracy %
Kellen Clemens STL ... 阅读全帖 |
|
d****g 发帖数: 253 | 40 Peyton Manning (Den - QB), Joe Flacco (Bal - QB)
RB
C.J. Spiller (Buf - RB), Bishop Sankey (Ten - RB), Darren Sproles (Phi - RB,
Shonn Greene (Ten - RB), Jonathan Grimes (Hou - RB)
WR
Sammy Watkins (Buf - WR), Roddy White (Atl - WR), Michael Floyd (Ari - WR),
Hakeem Nicks (Ind - WR)
TE
Martellus Bennett (Chi - TE), Coby Fleener (Ind - TE)
Denver (Den - DEF)
Robbie Gould (Chi - K)
今年是打酱油了, 目标是争取明年能有个好 Keeper. |
|
t******3 发帖数: 4053 | 41 1. Broncos at Pats
赛季之初看了野马的2014赛程,我当时就觉得最可能输掉的2场比赛就是海鸟,拍子这2
个客场。
目前野马,拍子战绩为6:1,6:2,这场比赛对我驴来说,即使输掉也不影响我们与拍子
争AFC 1st seed的大局(我们领先拍子一场)。但对拍子而言,他们势在必夺,因为后
面他们面对的是扣子,狮子,客场GB,客场茶几,赛程难度可想而知!这场一输,基本
就退出AFC 1st seed争夺。。。而如果在playoff到Mile High,堂哥知道那意味着什么
--- Orange Train Crush!
这场比赛对我驴的意义来说,Offense主要看客场恶劣环境下是否choke,而真正重点在
于测试野马Defense的抗压度。本赛季我驴offense水准已达SB-caliber,但谁都知道
playoff能走多远或能否夺得SB,取决于defense。因此,真正的驴饭目前关注的都是野
马defense的提升淬炼。
第9周野马defense的统计排名如下:
ranks 1st overall in rushing yards per game allowed ... 阅读全帖 |
|
h*******a 发帖数: 99 | 42 连续好几天compact$25都bid不上,有什么消息么?有没有人跟我一样呢
最新发现,说是bufflo市区没有name your own price服务(priceline上)
有没有人传授一下在piceline上bid机场租车的经验啊 |
|
|
h*******a 发帖数: 99 | 44 We're sorry. Rental Cars are not currently available for the location you
entered
选择Buffalo, NY USA竟然出这么个结果,咋回事啊 |
|
s******x 发帖数: 15232 | 45 不是非要PRICELINE上租车才可以便宜的。 |
|
h*******a 发帖数: 99 | 46 天啊,这么贵,我想bid 23-29,看到也得30+了 |
|