濮存昕,您忒牛逼了# Joke - 肚皮舞运动
s*e
1 楼
update:
收到invite onsite 通知,恩,国人还是挺靠谱的。感谢。
感谢NND的推荐,
不过可能被interviewer的国人给干掉了.
1.经典的stream求median,用2个heap解决。
2.给了一段程序,说一下程序的功能,
然后比较c程序和javascrip程序的区别。这个down掉。
#include
#include
#include
#include
#define MAX_RETRY 3
int remoteCall() {
return random() % 2;
}
void action(times) {
printf("calling remote procedure\n");
if (remoteCall()) {
printf("success!\n");
} else {
printf("error occured!\n");
if (times < MAX_RETRY) {
sleep(1);
action(times + 1);
} else {
printf("max retry reached\n");
}
}
}
int main(void) {
int numRetry = 0;
srand(time(NULL));
action(1);
return 0;
}
--------------------------------------------------------
------
js
--------------------------------------------------------
------
var action,
maxTimes = 3;
function remoteCall(cb) {
if (Math.floor(Math.random() * 2) === 0) {
cb("error occured!");
} else {
cb();
}
}
action = function (times) {
return function () {
console.log("calling remote procedure");
remoteCall(function (error) {
if (error) {
console.log(error);
if (times < maxTimes) {
setTimeout(action(times + 1), 1000);
} else {
console.log("max retry reached");
}
} else {
console.log("success!");
}
});
};
};
action(1)();
收到invite onsite 通知,恩,国人还是挺靠谱的。感谢。
感谢NND的推荐,
不过可能被interviewer的国人给干掉了.
1.经典的stream求median,用2个heap解决。
2.给了一段程序,说一下程序的功能,
然后比较c程序和javascrip程序的区别。这个down掉。
#include
#include
#include
#include
#define MAX_RETRY 3
int remoteCall() {
return random() % 2;
}
void action(times) {
printf("calling remote procedure\n");
if (remoteCall()) {
printf("success!\n");
} else {
printf("error occured!\n");
if (times < MAX_RETRY) {
sleep(1);
action(times + 1);
} else {
printf("max retry reached\n");
}
}
}
int main(void) {
int numRetry = 0;
srand(time(NULL));
action(1);
return 0;
}
--------------------------------------------------------
------
js
--------------------------------------------------------
------
var action,
maxTimes = 3;
function remoteCall(cb) {
if (Math.floor(Math.random() * 2) === 0) {
cb("error occured!");
} else {
cb();
}
}
action = function (times) {
return function () {
console.log("calling remote procedure");
remoteCall(function (error) {
if (error) {
console.log(error);
if (times < maxTimes) {
setTimeout(action(times + 1), 1000);
} else {
console.log("max retry reached");
}
} else {
console.log("success!");
}
});
};
};
action(1)();